You are on page 1of 8

Mining Better Technical Trading Strategies with Genetic Algorithms

Jiarui Ni and Chengqi Zhang


University of Technology, Sydney
PO Box 123, Broadway, NSW 2007, Australia
{jiarui, chengqi}@it.uts.edu.au

Abstract Backtesting is a concept closely related to trading strate-


gies. It is the concept of taking a strategy and going back
Technical analysis is one of the two main schools of in time to see what would have happened if the strategy
thought in the analysis of security prices. It is widely had been faithfully followed. The assumption is that if the
believed and applied by many professional and amateur strategy has worked previously, it has a good but not cer-
traders. However, it is often criticized for lacking scien- tain chance of working again in the future and conversely if
tific rigour or worse, for lacking any basis whatsoever. We the concept has not worked well in the past, it probably will
propose to explore the feasibility and/or limitation of techni- not work well in the future. Backtesting has been widely
cal analysis by the optimization of technical trading strate- used in the practice and research in stock markets and other
gies over historical stock data with genetic algorithms. This financial markets, and many commercial products such as
paper presents the optimization problem in detail and dis- MetaStock1 and TradeStation2 offer backtesting facility. It
cusses the potential problems to be tackled during the opti- helps the users learn how a trading strategy is likely to per-
mization. Preliminary experiments show that it can identify form in the marketplace. It also provides the users with the
the limitations quickly. opportunity to improve a trading strategy.
During the backtesting process, one can optimize the
parameters of a technical trading strategy based on a spe-
1 Introduction cific performance criterion and verify the optimal parame-
ters with out-of-sample data. With the optimization, it is
Technical analysis (or chartism) is the study of price possible to study the potential of a given trading strategy
movement and trend in markets in order to forecast future under various conditions. However, depending on the num-
prices. Many different methods and tools are utilized in ber and range of parameters, the optimization process may
technical analysis, but they all rely on the principle that be very time consuming. Genetic algorithm (GA) can be
price patterns and trends exist in markets that can be iden- used to reduce the computation requirement. Some work
tified and exploited. The rationality of technical analysis is has been reported in this area [15, 12, 13, 14], however,
based on the following three hypotheses: 1) price action in these reports focus on their specific targets and provide no
the market discounts everything; 2) prices move in trends; panorama of the problem.
and 3) history tends to repeat itself. [21] This paper tries to present a comprehensive description
Many market participants, especially active traders of this parameter optimization problem and summarize a list
(traders who are looking for quick profits), defend the prac- of issues to be addressed during the optimization process.
tice and believe (and in some cases demonstrate) that it can The purpose of this paper is to provide a guideline for fu-
be profitable. However, not all research agrees with this ture work in this area. The rest of this paper is organized
conclusion. Some academics and fundamentalist market as follows. Section 2 illustrates several technical trading
participants believe that technical analysis has no predictive strategies. Section 3 explains the backtesting process and
power. There is extensive research on technical analysis. the optimization with GA. Section 4 lists the problems to be
Some exhibit positive results for technical trading strate- tackled and points out how to get the work done efficiently.
gies [6, 8], some give negative results [17, 19], and others Finally, we conclude this paper with some suggestions for
show mixed results in different situations [5], or claim that future work.
technical analysis has forecasting ability but no profitability
[4, 16]. There has been no end to the debate so far, and the 1 Presented by Equis International (www.equis.com)
debate is doomed to continue for a long time, if not forever. 2 Presented by TradeStation Securities (www.tradestation.com)

Proceedings of the International Workshop


on Integrating AI and Data Mining (AIDM'06)
0-7695-2730-2/06 $20.00 © 2006
2 Technical Trading Strategies falls below) Mt by more than a certain percentage θ. The
signal St is given by
There are many types of technical trading strategies. 

 1 if Pt > (1 + θ)Mt (l)
Some of them can date back to tens or even hundreds of 


 and Pt−k < Mt−k (l)
years ago and have been widely known and applied in prac- 


 and Mt−i (l) ≤ Pt−i ≤ (1 + θ)Mt−i (l),
tice. Today, these classical strategies are taught in many 

 ∀ i ∈ {1, · · · , k − 1}
textbooks and online courses, and they have been imple- St = −1 if Pt < (1 − θ)Mt (l)
mented in various products. For example, Tradetrek3 in- 


 and Pt−n > Mt−n (l)
cludes at least eight technical trading strategies in its prod- 


 and Mt−i (l) ≥ Pt−i ≥ (1 − θ)Mt−i (l),
uct: moving average crosses, candle stick trend reversal, 


 ∀ i ∈ {1, · · · , n − 1}
head-and-shoulders, range breakout, triangle breakout, cup- 
0 otherwise
with-a-handle, triple top/bottom, and stochastic combo. (3)
As time goes on, the magic of classical strategies fades A double MA strategy compares two MAs with differ-
due to this and that reason such as the change of the market ent lengths l1 and l2 where l1 < l2 . If Mt (l1 ) rises above
situation or the over popular use of a strategy itself. As a Mt (l2 ), the security is bought and held until Mt (l1 ) falls
result, practitioners and researchers are also trying to con- below Mt (l2 ). The signal St is given by
struct new technical trading strategies that can make profit 
in the current markets. These new strategies may be con-  1


if Mt (l1 ) > Mt (l2 )
structed by simple modification to classical strategies, by 
 and Mt−k (l1 ) < Mt−k (l2 )


combination of several existing strategies, or even created 
 and Mt−i (l1 ) = Mt−i (l2 ),


from scratch by genetic programming [20]. 
 ∀ i ∈ {1, · · · , k − 1}
This paper does not try to cover every single technical St = −1 if Mt (l1 ) < Mt (l2 ) (4)


trading strategy. Instead, only one type of classical strate- 
 and M t−n (l 1 ) > M t−n (l 2 )


gies based on moving average is described below in order 
 and Mt−i (l1 ) = Mt−i (l2 ),


to illustrate how technical trading strategies work. 
 ∀ i ∈ {1, · · · , n − 1}

A moving average (MA) is simply an average of current 0 otherwise
and past prices over a specified period of time. An MA of
length l at time t is calculated as A double MA strategy can also be filtered by adding the
percentage requirement for triggering actions.
l−1 It should be noted that the values of l, l1 , l2 and θ in the
1
Mt (l) = Pt−i (1) above equations are not fixed. They are usually selected by
l i=0 experience or experiments.
MA strategies give one ‘sell’ signal after one ‘buy’ signal
where Pt−i is the price at time t − i. Various trading strate- and vice versa. There are no consecutive ‘buy’ signals nor
gies can be formulated based on MA. A simple MA strat- consecutive ‘sell’ signals. However, other trading strate-
egy compares the current price Pt to its MA Mt . If Pt rises gies, such as the one discussed in [15], may give consecu-
above Mt , the security is bought and held until the price tive ‘buy’ or ‘sell’ signals.
falls below MA at which time the security is sold. Mathe- The signal St indicates only the time when an action (buy
matically, the signal St is calculated as or sell) should be taken. However, a trading strategy also
 has to specify the volume V (or quantity) to be traded when

 1 if Pt > Mt (l) and Pt−k < Mt−k (l) a signal is triggered. Again, there is no established rule to



 and Pt−i = Mt−i (l), determine V . One strategy may specify a fixed V , while


 ∀ i ∈ {1, · · · , k − 1} another strategy may increase/decrease V step by step. For
St = −1 if Pt < Mt (l) and Pt−n > Mt−n (l) (2) example, one trading strategy says ‘when adding to a trade,



 and Pt−i = Mt−i (l), add only 14 to 12 as much as currently held’. The actual



 ∀ i ∈ {1, · · · , n − 1} V depends on many factors, such as the selected trading

0 otherwise strategy, the available fund, and the available volume in the
market, etc.
where k and n are arbitrary positive integers, 1 means ‘buy’,
−1 means ‘sell’, and 0 means ‘hold’ or ‘no action’.
A filtered MA strategy is more conservative than a sim- 3 Backtesting and Optimization
ple MA in that it only takes action when Pt rises above (or
When a trading strategy is fixed, it is relatively easy to
3 www.tradetrek.com backtest it. By simply collecting the relevant historical data

Proceedings of the International Workshop


on Integrating AI and Data Mining (AIDM'06)
0-7695-2730-2/06 $20.00 © 2006
and applying the trading strategy against the data, one can 4. Perform crossover and mutation.
easily learn the performance of the strategy under concern.
However, most of the time, trading strategies are not fixed. 5. Evaluate the performance of the new candidates.
Instead, they are parameterized, as illustrated in Section 2. 6. Stop if a termination criterion is met, otherwise go
In this case, the goal of backtesting becomes finding the pa- back to step 3.
rameters that optimize the performance of the given trading
strategy. Figure 1 shows the profit performance landscape For the purpose of avoiding the possibility of data-
of a simple trading strategy with two parameters X and Y. snooping, or for the purpose of testing the robustness of the
It is obvious that the performance function is not convex. optimized trading strategy, the total range of historical data
Furthermore, profit is only one measure of the performance should be split into an in-sample optimization period and
of a trading strategy. There are other measures such as the an out-of-sample test period. The in-sample data are used
risk. People usually want to maximize the profit while min- during the optimization process, and the out-of-sample data
imizing the risk at the same time. Therefore the parameter are then used to test if the optimized trading strategy works
optimization is actually multiobjective. well on unknown/future data.
In order to avoid the local optima, stochastic optimiza-
tion techniques are necessary for this task. There are a num- 4 Considerations in the Optimization of
ber of such optimization techniques, such as simulated an-
nealing (SA), tabu search (TS), genetic algorithm (GA), ant Technical Trading Strategies
colony optimization (ACO) and particle swarm optimiza-
tion (PSO), etc.[11] Each technique has its strength and This section tries to list the many issues to be tackled
weakness. In the case of multiobjective optimization, GA during the optimization of technical trading strategies with
is better than other candidates because of its natural paral- GA.
lelism and its maintenance of a population of solution can-
didates instead of a single one[1]. 4.1 Data Preparation

To backtest any trading strategy, one of the first tasks to


do is to collect the historical trading data. Different trading
strategies may require quite different data. Several factors
1500 have to be considered for the data preparation.

• Data period
1000

500
One aspect of data period is its length. A long-term
Z 0 trading strategy requires data of a long time period,
−500
such as a few years or even tens of years, while a few
15
10 weeks’ data are enough for an intraday trading strat-
−1000

35
30
25
20
egy. Another aspect of data period is its freshness.
−1500
1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0
50
45
40
X
A researcher may be only interested in a certain time
Y
range in the past, while a practitioner is definitely in-
terested in the most recent time range.

• Data details
Figure 1. Performance of a simple technical
Historical stock trading data can be roughly catego-
trading strategy with two parameters X and Y.
rized into two groups: daily data and intraday data.
Z is the profit.
Daily data usually include volume, open price, close
price, highest price and lowest price. Daily data may
GAs have been widely investigated and applied in many also include other aggregation data such as volume
areas since it was developed by John Holland in 1975 [10]. weighted average price (VWAP), etc. There may also
The GA procedure can be outlined as follows: be other information such as dividend. Intraday data
may include the following details: 1) the time, price
1. Create an initial population of candidates. and volume of every single trade; 2) the market depth
at any time during the day; 3) the details of every or-
2. Evaluate the performance of each candidate. der and its amendment, cancellation or execution, etc.
There may also be other information such as the iden-
3. Select the candidates for recombination. tity of the initiator of every order, etc.

Proceedings of the International Workshop


on Integrating AI and Data Mining (AIDM'06)
0-7695-2730-2/06 $20.00 © 2006
A long-term trading strategy usually utilizes only daily To access the intraday data more efficiently, one so-
data. The details of the intraday data are irrelevant for lution is to store them into a relational database, such
it. However, the trading strategies used by day traders as the commercial Oracle database or the open source
definitely need the intraday data. Price information is PostgreSQL database, and take advantage of the power
always necessary for any trading strategy, while vol- of the database management system (DBMS). How-
ume information may be negligible if the normal daily ever, this method will worsen the storage problem be-
transaction size is much greater than the planned in- cause a DBMS usually creates a lot of metadata such
vestment. as indices to facilitate its fast operations. When stor-
age is a real problem, one has to turn to compression
• Availability and cost techniques. The above-mentioned Microsoft data be-
Where and how can one get the historical trading data? come about 330 megabytes after being compressed by
For the daily data, it is easy and free to get them in gzip, i.e., the size is reduced to about only 11 per-
most cases. For example, Yahoo!Finance4 offers daily cent. However, the compression will degrade data ac-
data for free, and they can be downloaded to spread- cess performance because it is more costly to read a
sheet. As to the intraday data, there is hardly any free compressed file than to read a plain text file. There-
lunch. Usually one has to subscribe to a commercial fore, one has to compromise between storage and per-
data provider to get them, and the cost varies from one formance. For example, SMARTS6 stores its data in
provider to another. However, sometimes academia FAV format which splits the data into multiple files
can obtain intraday data for free provided that the data where each file contains only one day’s data, and then
are used for research only. For example, SIRCA5 pro- compresses these files separately. Thus, the storage re-
vides free data to many universities across Australia quirement is relatively low and the data access perfor-
and New Zealand for research purpose. As a thumb or mance is relatively high. All in all, one has to choose a
rule, the longer the time range is, and the more detailed proper storage format according to the actual hardware
the data are, the more difficult and costly it is to obtain environment to balance the storage and performance.
the data.
4.2 Test Configurations
• Data cleaning
There may be various problems with the obtained data,
such as missing or duplicated records, invalid values Once the historical trading data are ready, the next step
(e.g., a negative price or volume), etc. The data offered is to use them to backtest trading strategies as describe in
by commercial data providers usually are of high qual- Section 3. However, as mentioned above, many variables
ity and less troublesome, however, the quality of free have to be configured in order to perform the backtesting.
data from the Internet are seldom guaranteed. There- These variables are discussed below.
fore the data should be checked and cleaned if neces-
• Search space
sary before they can be used for backtesting.
As with any optimization problem, the search space
• Data storage has to be specified. In the case of trading strategy pa-
The size of daily data is usually small and it is rela- rameter optimization, this means to specify the range
tively stable among different equities. One year’s daily and step of each parameter. Taking the filtered MA
data take up about 10 kilobytes disk space. However, strategy described by Equation 3 as an example, it has
the size of intraday data tends to be very large and two parameters: length l and percentage θ. Obviously,
varies dramatically among different equities. For ex- l is a discrete variable and can only be a positive in-
ample, three years’ intraday data (2001 – 2003, in CSV teger, while θ is a continuous variable between 0 and
format) take up 3 gigabytes disk space for Microsoft 1. But this is too rough. The parameters have to be
(MSFT), 1 gigabytes for Yahoo (YHOO), while only specified more accurately, such as l is a positive inte-
less than 400 kilobytes for Alto Palermo S.A. (APSA) ger between 5 and 50, and θ is between 0.05 and 0.25,
because it is rarely traded. For the heavily traded equi- so that the search space is kept as small as possible.
ties like MSFT, the intraday data size is so large that it However, how can we know the proper range for each
is a problem to store the data and also very inefficient parameter? There are at least two possible solutions.
and time consuming to read all the records sequentially One is to ask domain experts to set the range accord-
and to make use of them. ing to their experience. The other is to determine the
range by pilot tests.
4 finance.yahoo.com
5 Securities Industry Research Centre of Asia-Pacific 6 Securities Markets Automated Research Trading and Surveillance

(www.sirca.org.au) (www.smarts.com.au)

Proceedings of the International Workshop


on Integrating AI and Data Mining (AIDM'06)
0-7695-2730-2/06 $20.00 © 2006
• Fitness function These parameters can affect both the efficiency and ef-
Fitness functions play an important role in GAs. With- fectiveness of the GA search. Again, experience and
out a well-defined fitness function, it is impossible for pilot tests are the two major weapons to configure them
a GA to evaluate the candidate under consideration. properly.
For the optimization of trading strategies, a straight-
forward fitness function is its performance. However, • In-sample/out-of-sample lengths
as mentioned above, there are various measures of the The lengths of the in-sample and out-of-sample peri-
performance of a trading strategy, such as profit and ods are also critical for the performance of a trading
risk, and they are often contradictory to each other. It is strategy. These lengths mainly depend on the spe-
impossible to optimize every measure at the same time, cific trading strategy to be backtested. If a strategy
instead, some kind of compromise has to be made. is designed to work over a long period, the lengths of
One choice is to construct a fitness function that com- in-sample and out-of-sample periods have to be long
bines all the measures under concern. For example, enough for the strategy to take effect. For example,
the Sharpe ratio combines both return and risk and [16] took eight years (from 1982 to 1989) as in-sample
becomes a measure of risk-adjusted performance of a period and another eight years (from 1990 to 1997) as
trading strategy. It is defined as out-of-sample period. However, if a strategy is meant
to work within a short time, the lengths of in-sample
< R − Rf > and out-of-sample periods can also be modestly short,
S= (5) such as the one month of both in-sample and out-of-
σ
sample periods used in [14]. Besides, the in-sample
where R is the asset return, Rf is an expected return and out-of-sample periods do not have to be of equal
of another “standard” asset, such as the risk free rate of lengths. For instance, [2] used an in-sample period
return, < R − Rf > is the expected value of the excess from 1929 to 1935 and an out-of-sample from 1936
of the asset return over the risk free return, and σ is to 1995 in one test.
the standard deviation of the asset returns. The trading In-sample and out-of-sample periods are not static. In
strategy with the higher Sharpe ratio gives more return fact, the same period can serve as both in-sample and
for the same risk. When the Sharpe ratio is adopted as out-of-sample period at different stages in an experi-
the fitness function, GA will be directed to candidates ment. For example, when there are one year’s data,
with both higher returns and lower risks (in a relative and a trading strategy requires one month for both in-
sense). sample and out-of-sample periods, the backtesting can
Another choice is to use multi-objective optimization be carried out in this way. First, the first month is used
techniques and to search for the Pareto optimal instead as the in-sample period and the second month as the
of a conventional optimal. [1] provides good discus- out-of-sample period. Next, the second month serves
sions in this area. as the in-sample period and the third month as the out-
Different people have different preferences regarding of-sample period. And so on and so forth.
the many performance measures. For instance, young Because the in-sample and out-of-sample lengths rely
people tend to try riskier strategies in order to achieve on the trading strategy, they are usually set according
higher returns, while the aged may prefer to less risky to domain experts’ experience. Pilot tests may also
strategies with lower returns. Therefore, different fit- help in determining their values.
ness functions should be chosen to satisfy different
preferences. 4.3 Implementation and Execution
• GA parameters Now the data are ready and all the configurations are
Every GA has some inherent parameters for its opera- properly set, it is time to implement the GA and let it run,
tion. Some most commonly used parameters are listed and the time problem emerges. Depending on the complex-
below. ity of a trading strategy, it might require a considerable time
p population size to evaluate a single candidate. And remember, a GA has to
evaluate hundreds or thousands of candidates before it finds
c crossover probability the optimal. As a result, the time requirement may make the
m mutation probability backtesting infeasible. Therefore the implementation has to
be efficient. [15] has illustrated this problem in detail and
G1max maximum number of generations allowed proposed to use Parallel GA and to re-use intermediate re-
G2max maximum number of iterations without improve- sults as much as possible in order to reduce computation
ment time.

Proceedings of the International Workshop


on Integrating AI and Data Mining (AIDM'06)
0-7695-2730-2/06 $20.00 © 2006
5 Preliminary Experimental Results ANZ.AX
30

Some preliminary experiments have been carried out in


light of the above discussions. In this section we will de- 25

scribe our experiment settings and present some rudimen-


tary results based on the experiments. 20

5.1 Experimental Settings


15

Data
10

We carry out our experiments over the historical daily data


of 3 securities traded on the Australian stock exchange,
namely, ANZ, BIL and ERA. The data are downloaded from 5
0 500 1000 1500 2000 2500 3000

Commonwealth Securities Ltd.7 for free as CSV files and


contain open price, close price, highest price, lowest price
and volume. The time range is from June 1996 to August Figure 2. Price curve of ANZ
2006 and comprises about 2500 trading days. The close
price history of these 3 securities are shown in Fig. 2, 3 and BIL.AX
14
4, respectively. These 3 securities are selected because their
price curves can represent the curves of most of the securi-
12
ties in the ASX50 index.
10

Trading strategies
We have implemented the following 5 trading strategies for 8

our experiments:
6

BB Bollinger band with stop loss


4
CBO Filtered channel break out

KD Slow stochastic oscillator cross/rising and stop loss 2


0 500 1000 1500 2000 2500 3000

MA Filtered double moving average


Figure 3. Price curve of BIL
RSI Relative strength indicator with retrace and stop loss

The details of these trading strategies are not closely rel- 18


ERA.AX

evant to this paper and are not discussed here. Interested


16
readers can refer to [3, 18] for further information. The typ-
ical settings of various trading strategies are also obtained 14

from [3]. These trading strategies are applied in a series 12


of tests described below and are compared with the simple
buy-and-hold strategy. 10

GA settings 6

The parameters of all the trading strategies are encoded as 4

real numbers. As a rule of thumb, integers are used for num- 2


ber of periods, e.g., l, and floating point numbers are used
for percentage values, such as θ). The best candidate of each 0
0 500 1000 1500 2000 2500

generation is always kept in the next generation. Roulette


selection based on fitness values is used. The crossover and
7 www.comsec.com.au
Figure 4. Price curve of ERA

Proceedings of the International Workshop


on Integrating AI and Data Mining (AIDM'06)
0-7695-2730-2/06 $20.00 © 2006
mutation operations are similar to those described by [9] on Table 2 and 4 show that for securities whose prices rise
pages 59–60. stably, BH works better than all the trading strategies under
After some pilot tests, we set the GA parameters as fol- consideration. Although Test 2 shows that KD, MA and
lows: p = 18, c = 0.9, m = 0.05, G1max = 100 and RSI theoretically might beat BH, Test 3 and 4 show that
G2max = 5. Besides, we use the restart technique of micro practically they can never achieve it.
GA [7] to make sure that the best result found by our GA is For securities whose prices are more volatile, Table 3
close enough to the real optimum. The restart number is set shows that some trading strategies may achieve better re-
to 5 according to pilot tests. sults than BH. However, it is still not guaranteed. More
In this experiment, we only use the profit as the fitness work has to be done to reach some reliable conclusion.
function.
Table 1. Profits of buy-and-hold strategy
Tests ANZ BIL ERA
23352.9 10196.4 64179.7
Four tests have been designed to evaluate the effectiveness
of GA. The data are divided into in-sample and out-of-
sample data. The in-sample data comprises year 1997 and
1998, while the out-of-sample data comprises of year 1999
to 2005. To compare the various trading strategies, we con- Table 2. Test results for ANZ
cern only the profit over the out-of-sample period. Test 1 Test 2 Test 3 Test 4
Test 1 applies the 5 trading strategies with typical set- BB 12499.1 22260.3 11055.0 11355.7
tings over the out-of-sample data. It shows the performance CBO 8680.6 23284.0 10084.6 14466.7
of the trading strategies with a typical fixed setting. These KD 9399.5 23616.8 12959.3 13942.0
settings are usually given by professionals or set default by MA 10919.1 27206.7 20662.8 14882.9
some trading tools. RSI 10501.4 29020.1 6617.2 17145.6
Test 2 applies GA over the out-of-sample data to see
the maximal profits that various trading strategies might
achieve. These are only theoretical values since the opti-
mal settings can only be found when the historical data are Table 3. Test results for BIL
available and no one can really trade with these optimal set- Test 1 Test 2 Test 3 Test 4
tings. BB 5370.4 26754.7 11790.7 13199.1
Test 3 applies GA over the in-sample data to find the best CBO 4021.8 25273.3 18193.5 11010.0
parameters for the in-sample period and then apply these KD 22960.7 48164.3 8782.5 15755.4
parameters to the out-of-sample data. MA 5416.0 23332.0 9001.0 6202.4
Test 4 is a modified version of Test 3. Here, the in- RSI 10638.2 31330.6 18655.3 6014.9
sample data and out-of-sample data are no longer fixed as
before. Instead, we repeatedly use 2 years’ data as in-
sample data and the following year’s data as out-of-sample
data.
Table 4. Test results for ERA
Test 1 Test 2 Test 3 Test 4
5.2 Results and Discussions
BB 21039.6 63006.9 40942.2 8478.3
CBO 19011.1 61864.3 21997.3 25977.8
All the 4 tests are carried out against the 3 securities with KD 11355.1 73456.8 4923.0 12211.6
an initial capital of 10000 dollars. A transaction cost of
MA 9633.8 81626.7 9808.0 11706.5
0.2% of the traded value is charged for each trade (buy or
RSI 16438.1 95818.7 19540.0 17927.1
sale). Table 1 lists the final capital if the simple buy-and-
hold strategy (BH) is applied to each security over the out-
of-sample period. Table 2, 3 and 4 shows the results of the
4 tests over ANZ, BIL and ERA, respectively.
A quick conclusion is that BB and CBO are useless for 6 Conclusions and Future Work
ANZ and ERA since Test 2 shows that they have no chance
to beat the simple buy-and-hold strategy at all. Given that In this paper we have explained the problem of parame-
GA executes pretty fast, it can help rule out these fruitless ter optimization of technical trading strategies with genetic
trading strategies quickly. algorithms and discussed the many considerations during

Proceedings of the International Workshop


on Integrating AI and Data Mining (AIDM'06)
0-7695-2730-2/06 $20.00 © 2006
the optimization from data preparation to algorithm imple- [12] L. Lin, L. Cao, J. Wang, and C. Zhang. The applications
mentation. of genetic algorithms in stock market data mining optimiza-
With the guideline provided in this paper, preliminary tion. In Proceedings of Fifth International Conference on
experimental results show that GA can help with fast iden- Data Mining, Text Mining and their Business Applications,
tification of some limitations of technical trading strategies, pages 273–280, 2004.
[13] L. Lin, L. Cao, and C. Zhang. Genetic algorithms for ro-
but it is still hard to give any positive conclusions about the
bust optimization in financial applications. In M. H. Hamza,
profitability of trading strategies. Further work will try to editor, The IASTED International Conference on Computa-
find out if there are any situations where technical trading tional Intelligence (CI’2005), pages 387–391, 2005.
strategies have a large probability to work well. [14] L. Lin, D. Luo, and L. Liu. Mining domain-driven correla-
tions in stock markets. In S. Zhang and R. Jarvis, editors, AI
Acknowledgement 2005: Advances in Artificial Intelligence: 18th Australian
Joint Conference on Artificial Intelligence, pages 979–982,
2005.
This work was supported in part by the Australian [15] J. Ni and C. Zhang. An efficient implementation of the back-
Research Council (ARC) Discovery Projects (DP0449535 testing of trading strategies. In Y. Pan, D. Chen, M. Guo,
and DP0667060), National Science Foundation of China J. Cao, and J. Dongarra, editors, Third International Sym-
(NSFC) (60496327) and Overseas Outstanding Talent posium on Parallel and Distributed Processing and Appli-
Research Program of Chinese Academy of Sciences cations (ISPA’2005), LNCS 3758, pages 126–131. Springer
(06S3011S01). Verlag, 2005.
[16] R. Pereira. Forecasting ability but no profitability: an em-
pirical evaluation of genetic algorithm-optimised technical
References trading rules. Technical Report 99.06, La Trobe - Depart-
ment of Economics, 1999.
[1] A. Abraham and L. Jain. Evolutionary multiobjective opti- [17] M. J. Ready. Profits from technical trading rules. Financial
mization. In A. Abraham, L. Jain, and R. Goldberg, editors, Management, 31(3), 2002.
Evolutionary Multiobjective Optimization, Advanced Infor- [18] Stockcharts. http://stockcharts.com/education/IndicatorAnalysis/,
mation and Knowledge Processing, pages 1–6. Springer Ver- 2006.
lag London, 2005. [19] R. Sullivan, A. Timmermann, and H. White. Data-snooping,
[2] F. Allen and R. Karjalainen. Using genetic algorithms to technical trading rule performance, and the bootstrap. Jour-
find technical trading rules. Journal of Financial Economics, nal of Econometrics, 54:1647–1691, 1999.
51:245–271, 1999. [20] J. Wang. Trading and hedging in S&P 500 spot and fu-
[3] Ashcon. http://www.ashkon.com/predictor/strategies.html, tures markets using genetic programming. Journal of Fu-
2006. tures Markets, 20:911–942, 2000.
[4] E. R. Dawson and J. M. Steeley. On the existence of vi- [21] Wikipedia. Technical analysis.
sual technical patterns in the UK stock market. Journal of http://en.wikipedia.org/wiki/Technical analysis, 2006.
Business Finance and Accounting, 30 1/2:263–293, 2003.
[5] F. Fernández-Rodrı́guez, C. González-Martel, and
S. Sosvilla-Rivero. On the profitability of technical trading
rules based on artificial neural networks: Evidence from
the Madrid stock market. Economics Letters, 69(1):89–94,
2000.
[6] R. Gençay. Optimization of technical trading strategies and
the profitability in security markets. Economics Letters,
59(2):249–254, 1998.
[7] D. E. Goldberg. Sizing populations for serial and parallel
genetic algorithms. In J. D. Schaffer, editor, Proceedings of
the Third International Conference on Genetic Algorithms,
pages 70–79. Morgan Kaufmann Publisher, San Mateo, Cal-
ifornia, 1989.
[8] A. Gunasekarage and D. M. Power. The profitability of
moving average trading rules in south asian stock markets.
Emerging Markets Review, 2(1):17–33, 2001.
[9] R. L. Haupt and S. E. Haupt. Practical Genetic Algorithms.
John Wiley & Sons, Inc., New York, USA, 1998.
[10] J. H. Holland. Adaptation in Natural and Artificial Systems.
The University of Michigan Press, Ann Arbor, USA, 1975.
[11] M. T. Jones. AI application programming. Charles River
Media, Hingham, Mass., USA, 2005.

Proceedings of the International Workshop


on Integrating AI and Data Mining (AIDM'06)
0-7695-2730-2/06 $20.00 © 2006

You might also like