Professional Documents
Culture Documents
Improving Technical Trading Systems by Using A New MATLAB Based Genetic Algorithm Procedure
Improving Technical Trading Systems by Using A New MATLAB Based Genetic Algorithm Procedure
Improving Technical Trading Systems by Using A New MATLAB Based Genetic Algorithm Procedure
on NON-LINEAR ANALYSIS, NON-LINEAR SYSTEMS and CHAOS, Sofia, Bulgaria, October 27-29, 2005 (pp129-134)
Abstract: - Recent studies in financial markets suggest that technical analysis can be a very useful tool in
predicting the trend. Trading systems are widely used for market assessment however parameter optimization
of these systems has adopted little concern. In this paper, to explore the potential power of digital trading, we
present a new MATLAB tool based on genetic algorithms, which specializes in parameter optimization of
technical rules. It uses the power of genetic algorithms to generate fast and efficient solutions in real trading
terms. Our tool was tested extensively on historical data of a UBS fund investing in Emerging stock markets
through a specific technical system. Results show that our proposed GATradeTool outperforms commonly
used, non-adaptive, software tools with respect to the stability of return and time saving over the whole sample
period.
information. These techniques can be easily where Close is the closing price of the fund at time t
extended to include other types of information such and function MovAv calculates the simple moving
as technical and macroeconomic data as well as past average of the variable Close with time length θ1.
prices. 1 θ1 −1 (2)
MovAv (Close , θ ) =
t 1 ∑ Close , t = θ 1 ,θ 1 + 1,..., Ν
t −i
According to [14], genetic algorithm is an θ1 i =0
appropriate method to discover technical trading Our trading system consists of two indicators, the
rules. Fernandez-Rodriguez et al [15] by adopting Dimbeta indicator and the Moving Average of
genetic algorithms optimization in a simple trading Dimbeta given by the following equation.
rule provide evidence for successful use of GAs MovAv ( Dimbeta , θ ) =
1 θ 2 −1
Dimbeta , t = θ ,θ + 1,..., Ν
(3)
t 2 ∑ t −i 2 2
can easily handle the binary variables. Secondly, The optimization problem is set as to determine the
GAs search from a population of points, not a single optimal lengths of Dimbeta indicator and its moving
point. Therefore GAs can provide a set of globally average for the simple Dimbeta model that will
optimal solutions. Finally, GAs use only objective maximize profits. Firstly, the effect of different GA
function information, not derivatives or other parameter configurations will be studied. More
auxiliary knowledge. Therefore GAs can deal with specifically we are interested to measure the effect
the non-continuous and non-differentiable functions of the population size and the crossover parameter in
that are actually existed in a practical optimization the performance of the genetic algorithm based
problem. optimization procedure. According to previous
research recommendations [20], [12], [24], the
2.1.1 Proposed GATradeTool population size should be equal to 30 and the
In GATradeTool, Genetic Algorithm operates on a crossover rate should be 0,6 (default values). The
population of candidate solutions encoded. Each number of iterations was set to 300 for all
decision variable in the parameter set is encoded as a simulations. Secondly, we compared the solutions of
binary string and these are concatenated to form a optimization problem conducted by different
chromosome. It begins with a randomly constructed software tools in order to measure the validity of the
population of initial guesses. These solution GATradeTool proposed.
candidates are evaluated in terms of our objective Table 1 provides the GA optimization results for
function (equation 4). In order to obtain optimality different size of populations. The first row of the
each chromosome exchanges information by using table shows the best parameters for the Dimbeta
operators (i.e. crossover1 and mutation2) borrowed indicator and the moving average of Dimbeta. In
from natural genetic to produce the better solution. order to measure the effect of the population size in
The objective function (equation 4) is used to the best solution we examine a series of different
provide a measure how individuals have performed statistics. The solution with the maximum and
in the problem domain. In our case, the most fitted minimum return, the average return, the standard
individuals will have the highest numerical value of deviation of these solutions, the time needed for
the associated objective function. The fitness convergence of the algorithm, and an efficiency
function transforms the raw objective function index calculated by dividing max return solution by
values into non-negative figures of merit for each the standard deviation of solutions.
individual. The tool supports the offsetting and By looking in table 1 we can say that as long as you
scaling method [20] and the linear-ranking increase the population size the best and the average
algorithm [22]. solutions are higher. However, after a population
Following genitor selection method [23] we ranked size of 30 the performance decreased. In order to
all individuals of a population according to take into consideration the computational costs
performance based on return. Better performers involved since increase in population size, we
replaced the poor performers. These candidates were calculate the time needed for solving the problem.
allowed to participate in the crossover and possible Low population size leads to low performance and
mutation. The procedure that recombines promising low completion time. According to the efficiency
candidates in order to create the next generation is index the best solution is that given by the
known as crossover. Finally random mutations [13] population size 20.
are introduced in order to avoid local optima. These
steps were repeated until a well-defined criterion is
satisfied. Table 1 Population Size Effect
3 Problem Solution
In this section, we apply our methodology in a UBS
Mutual Fund investing in emerging stock markets.
The data analyzed consists of 2800 observations on
daily closing prices of that fund for the period 1/5/98
– 25/6/04. The optimization period is defined Table 2 gives the results of the genetic optimization
between 1/5/98 to 25/6/03. The optimized system procedure by altering the crossover rate between 1
was evaluated through the extended period 25/6/03 and 0.2 for the population size selected from
to 25/6/04. previous table (i.e. 20). The structure of this table is
the same like the previous one. For example, when
4th WSEAS Int. Conf. on NON-LINEAR ANALYSIS, NON-LINEAR SYSTEMS and CHAOS, Sofia, Bulgaria, October 27-29, 2005 (pp129-134)
crossover rate is one, the GA found that the (population size 80, crossover rate 0,6). It can be
Dimbeta(203,179) had the best performance of observed that the maximum return has a positive
126,39% profit. The second row given the time trend. It appears to be relatively stable after 150
needed to reach the optimal solution. The next rows generations and moves in the range between 1.2 and
give statistics on the evolution process. All 1 (ie. 120%-100% return). For the minimum fitness
configuration studied appear to converge to near no pattern seems to exist. For the average population
optimal solutions, producing large positive profits. return a clear upward trend can be found in the first
In order to assess the appropriateness of a specific 180 generations, this is an indication that the overall
crossover rate, since the models have different initial fitness of the population improves over time.
populations (i.e. initial set of random numbers, the Concerning the volatility of the solutions, standard
initial conditions) and find different optimal deviation of solutions after an increase in the first
solutions we will examine the stability of the generations stabilizes in a range between 0.3 and 0.6
average by using the standard deviation measure. providing evidence of a stable and efficient set of
We can see that the most “stable” average solutions.
population fitness appears for a crossover rate of
60%, this confirms the configuration suggested in
the literature.
By looking at Table 3 you can compare the results Fig.2 Evolution of statistics over 300 generations
of optimization of our trading system by using three
different software tools. The first row gives the Figure 3 provides a three dimensional plot of the
result for the GATradeTool against the Metastock optimum solutions given by the GATradeTool. In
and the FinTradeTool. Our proposed software tool axes x and y we have the parameters θ1, θ2 for the
(GATradeTool) can solve the optimization problem dimbeta indicator and its moving average. Axis 2
very fast without any specific restrictions about the shows the return of the Dimbeta trading system for
number of total tests. The maximum number of test the selected optimum parameters. As can be easily
that can be performed in Metastock software is understood our tool provides an area of optimum
32000. The FinTradeTool needs much more time in solutions in contrast with the FinTradeTool that
order to find the optimal solution. The solution provides only the best solution.
provided by the GATradeTool, is closed to the
optimal solution of the FinTradeTool.
order to implement a genetic algorithm tool that can [8] Papadamou, S. and Tsopoglou, S., Investigating
improve optimization of technical trading systems. the profitability of Technical Analysis Systems
Our experiment results show that GATradeTool can on foreign exchange markets, Managerial
improve digital trading by providing quickly a set of Finance, Vol.27, No.8, 2001, pp. 63-78.
near optimum solutions. Concerning the effect of [9] Lo, A.W. and MacKinlay, A.C., When are
different GA parameter configurations, we found contrarian profits due to stock market
that an increase in population size can improve overreaction? Review of Financial Studies,
performance of the system. The parameter of Vol.3, 1990, pp. 175-206.
crossover rate does not affect seriously the quality of [10] Brown, S., W. Goetzmann and S. Ross,
the solution. Survival, Journal of Finance, Vol.50, 1995, pp.
By comparing the solutions of the optimisation 853-873.
problem conducted by different software tools, we [11] Papadamou, S. and Stephanides, G., A New
found that the GATradeTool can perform better, by Matlab-Based Toolbox For Computer Aided
providing very fast a set of optimum solutions that Dynamic Technical Trading, Financial
present a consistency in all over the evaluation Engineering News, Vol. May/June, No.31, 2003.
period. [12] Bauer, R. J. and G. E. Liepins, Genetic
Finally, it would be interesting for further research Algorithms and Computerized trading strategies,
to test a series of different systems in order to see In Expert Systems in Finance, edited by D.E.
the correlation between genetic algorithm and O’Leary and P.R. Watkins, Amsterdam, The
system performances. In our days of frequent Netherlands: Elsevier Science Publishers, 1992.
changes in financial markets the researchers and [13] Bauer, R. J. Jr., Genetic Algorithms and
traders can easily test their specific systems in Investment Strategie, New York, John Wiley &
GATradeTool by changing only the function that Sons, Inc, 1994.
produce the trading signals. [14] Allen, F. and Karjalainen, R., Using genetic
algorithms to find technical trading rules,
Journal of Financial Economic, Vol. 51, 1999
References: pp. 245-271.
[1] Jegadeesh, N. and Titman, S., Returns to Buying [15] Fernández-Rodríguez, F., González-Martel, C.
Winners and Selling Losers: Implications for and Sosvilla-Rivero, S., Optimisation of
Stock Market Efficiency, Journal of Finance, Technical Rules by Genetic Algorithms:
Vol.48, No.1, 1993, pp. 65-91. Evidence from the Madrid Stock Market,
[2] Lehmann, B. N., Fad, martingales, and market Working Papers 2001-14, FEDEA
efficiency, Quarterly Journal of Economics, (ftp://ftp.fedea.es/pub/Papers/2001/dt2001-
Vol.105, 1990, pp. 1-28. 14.pdf)
[3] Werner, F.M., Bondt, D. and Thaler, R., Further [16] Mahfoud, S. and Mani, G., Financial
Evidence on Investor Overreaction and Stock Forecasting Using Genetic Algorithms, Journal
Market Seasonality, Journal of Finance, Vol.42, of Applied Artificial Intelligence,Vol.10,No.6,
No.3,1987, pp. 557-581. 1996, pp. 543-565.
[4] Menkhoff, L. and Schlumberger, M., Persistent [17] Neely, C., Weller, P. and Ditmar, R., Is
Profitability of Technical Analysis on Foreign technical analysis in the foreign exchange market
Exchange Markets? BNL Quarterly Review, profitable? A genetic programming approach, in
Vol.193, 1995, pp. 189 - 216. Dunis, C. & Rustem, B.(ed.), Proceedings,
[5] Brock, W., Lakonishok, J. and LeBaron, B., Forecasting Financial Markets: Advances for
Simple technical trading rules and the stochastic Exchange Rates, Interest Rates and Asset
properties of stock returns, Journal of Finance, Management, London, 1997.
Vol.47, 1992, pp. 1731-1764. [18] Oussaidene, M., Chopard, B., Pictet, O. and
[6] Allen, H. L. and Taylor, M. P., The use of Tomassini, M., Practical aspects and experiences
technical analysis in the foreign exchange – Parallel genetic programming and its
market, Journal of International Money and application to trading model induction, Journal
Finance, Vol.11, 1992, pp. 303 - 314. of Parallel Computing, Vol.23, No.8, 1997, pp.
[7] Cheung, Y. W. and Wong, C. Y. P., The 1183-1198.
Performance of Trading Rules on Four Asian [19] De Jong, K., An Analysis of the behavior of a
Currency Exchange Rates. Multinational class of Genetic Adaptive Systems, Ph.D. diss.,
Finance Journal, Vol.1, 1997, pp. 1 - 22. University of Michigan, University Microfilms
No. 76-9381, 1975.
4th WSEAS Int. Conf. on NON-LINEAR ANALYSIS, NON-LINEAR SYSTEMS and CHAOS, Sofia, Bulgaria, October 27-29, 2005 (pp129-134)
Footnotes
1 Arithmetic single-point crossover, involves randomly
cutting two strings at the same randomly determined
string position and then swapping the tail portions.
Crossover extends the search for new solutions in far-
reaching directions.
2 Mutation is a genetic operation that occurs with low
frequency and alerts one character in a particular string
position. For example a 0 in a string could be altered to 1,
or vice versa, through mutation.
Acknowledgements:
This research paper was part of the postdoctoral research
of Dr. S. Papadamou that has been funded by IKY Greek
State Scholarships Foundation.