Generating Moving Average Trading Rules on the Oil Futures Market with Genetic Algorithms
Post on: 18 Октябрь, 2015 No Comment
Generating Moving Average Trading Rules on the Oil Futures Market with Genetic Algorithms
1 School of Humanities and Economic Management, China University of Geosciences, Beijing 100083, China
2 Key Laboratory of Carrying Capacity Assessment for Resource and Environment, Ministry of Land and Resources, Beijing 100083, China
3 Lab of Resources and Environmental Management, China University of Geosciences, Beijing 100083, China
4 Institute of China’s Economic Reform and Development, Renmin University of China, Beijing 100872, China
Received 19 February 2014; Revised 4 May 2014; Accepted 7 May 2014; Published 26 May 2014
Academic Editor: Wei Chen
Abstract
The crude oil futures market plays a critical role in energy finance. To gain greater investment return, scholars and traders use technical indicators when selecting trading strategies in oil futures market. In this paper, the authors used moving average prices of oil futures with genetic algorithms to generate profitable trading rules. We defined individuals with different combinations of period lengths and calculation methods as moving average trading rules and used genetic algorithms to search for the suitable lengths of moving average periods and the appropriate calculation methods. The authors used daily crude oil prices of NYMEX futures from 1983 to 2013 to evaluate and select moving average rules. We compared the generated trading rules with the buy-and-hold (BH) strategy to determine whether generated moving average trading rules can obtain excess returns in the crude oil futures market. Through 420 experiments, we determine that the generated trading rules help traders make profits when there are obvious price fluctuations. Generated trading rules can realize excess returns when price falls and experiences significant fluctuations, while BH strategy is better when price increases or is smooth with few fluctuations. The results can help traders choose better strategies in different circumstances.
1. Introduction
Energy is vital for economic development. Household activities, industrial production, and infrastructure investments all consume energy directly or indirectly, no matter in developing or developed countries [1 ]. Issues pertaining to energy trade [2 ], energy efficiency [3 ], energy policy [4 –6 ], energy consumption [7 ], and energy finance [8 ] have received more importance in recent years. Crude oil futures market is a crucial part of energy finance within the scope of the global energy market. Traders and researchers employ technical analysis tools to identify gainful trading rules in financial markets. Accordingly, moving average indicators are commonly used in technical analysis to actualize greater returns. This paper attempts to answer whether in real life an investor can use moving average technical trading rules to obtain excess returns through searching for profitable moving average trading rules with genetic algorithms in the crude oil futures market.
Genetic algorithms are widely used in social sciences [9. 10 ], especially in certain complex issues where it is difficult to conduct precise calculations. It is a trend to apply physical or mathematical methods in energy and resource economics [11 –16 ]. Researchers have applied genetic algorithms to the prediction of coal production-environmental pollution [17 ], the internal selection and market selection behavior in the market [18 ], the crude oil demand forecast [19 ], the minimization of fuel costs and gaseous emissions of electric power generation [20 ], and the Forex trading system [21 ]. With respect to the financial technical analysis issues, scholars use genetic algorithms to search best trading rules and profitable technical indicators when making investment decisions [22 –25 ]. Genetic algorithms are combined with other tools such as the agent-based model [26 ], fuzzy math theory [27 ], and neural networks [28 ]. There are also some studies that have used genetic algorithms to forecast the price trends in the financial market [29. 30 ] or the exchange rate of the foreign exchange market [31 ]. As there are a vast number of technical trading rules and technical indicators available in the crude oil futures market, it is impractical to use ergodic calculations or certain other accurate calculation methods. Therefore, using genetic algorithms is a feasible way to resolve this issue.
Moving average indicators have been widely used in studies of stocks and futures markets [32 –37 ]. Two moving averages of different lengths are compared to forecast the price trends in different markets. Short moving averages are more sensitive to price changes than long ones. If a short moving average price is higher than a long period moving average price, traders will believe the price will rise and take long positions. When the short moving average price falls and crosses with the long one, opposite trading activities will be taken [38 ]. Allen and Karjalainen (AK) [39 ] used genetic algorithms to identify technical trading rules in stock markets with daily prices of the S&P 500. The moving average price was used as one of the many indicators of the technical rules. Other indicators, such as the mean value and maximum value, are also used when making investment decisions. Wang [40 ] conducted similar research on spot and futures markets using genetic programing, while How [41 ] applied AK’s method to different cap stocks to determine the relevance of size. William, comparing different technical rules and artificial neural network (ANN) rules regarding oil futures market, determined that the ANN is a good tool, thus casting doubt on the efficiency of the oil market [38 ]. All of these studies combine moving average indicators with other indicators to generate trading rules. However, in this paper, we utilize moving averages to generate trading rules, which may be a simple and efficient approach.
The performance of a moving average trading rule is affected significantly by the period lengths [42 ]. Therefore, finding optimal lengths of the two periods above is a central issue in technical analysis literature. A variety of lengths have been tried in existing research projects [43 –48 ]. In the existing research, most of moving average rules use fixed moving average period lengths and single moving average calculation method. However, it is better to use variable lengths for different investment periods [49. 50 ] and there are different types of moving average calculation method that can be used in technical analysis.
In this paper, considering that the optimal length of the moving average periods and the best calculation method may vary from one occasion to another we use genetic algorithms to determine the suitable length of the moving average period and the appropriate method. Six moving average calculation methods are considered in this paper and genetic algorithms can help us find out the best method and appropriate period lengths for different circumstances. Accordingly, we are able to present the most suitable moving average trading rules for traders in the crude oil futures market.
2. Data and Method
www.eia.gov/dnav/pet/pet_pri_fut_s1_d.htm ). We select 20 groups of sample data, each containing 1000 daily prices. In the 1000 daily prices, a 500-day price series is used to train trading rules in every generation. The following 200 prices are used to select the best generated trading rule from all generations, and the last 300 daily prices are used to determine whether the generated rule can acquire excess returns. The first group begins in 1985, the last group ends in 2013, and each 1000-day price series with a step of 300 is selected. We must also include 500 more daily prices before each sample series to calculate the moving prices for the sample period. Thus, every independent experiment requires a 1500-day price series. The data we use are presented in Figure 1 .
Moving average trading rules facilitate decision-making for traders by comparing two moving averages of different periods. In this way, traders can predict the price trend by analyzing the volatility of the moving average prices. There are six moving average indictors usually used in technical analysis: simple moving average (SMA), weighted moving average (WMA), exponential moving average (EMA), adaptive moving average (AMA), typical price moving average (TPMA), and triangular moving average (TMA). The calculation methods of moving average indicators are presented in Table 1 .
To use a moving average trading rule in the oil futures market, at least three parameters must be set to establish a trading strategy. These parameters include the lengths of two moving average periods and the choice of the moving average method from the above six types. Other researchers have used different lengths of sample periods in their studies. In this paper, we use genetic algorithms to determine appropriate lengths of the moving average period. According to existing literature, the long period is generally between 20 and 200 days (very few studies use periods longer than 200 days) [38. 39 ], and the short period is generally no longer than 60 days.
If the long average price is lower than the short average price, a trader will take a long position. It follows that in opposite situations, opposite strategies will be adopted. Noting the price volatility in the futures market, taking a long position when the short average price exceeds the long average price by at least one standard deviation in the short period may be a good rule. Conversely, taking a short position may also be a good rule. Therefore, we designed the two rules in our initial trading rules. The detailed calculation methods of the six moving averages are presented in Figure 2 .
Figure 2: Structure of trading rules.
A 17-binary string is used to represent a trading rule in which a seven-binary substring represents (M-N) (
is the long period length and
The calculation method of the return rate references AK’s method. The difference is that we allow a trader to hold a position for a long time, and we do not calculate the return every day. Consider