Mathias Bucher†
Institute for Empirical Research in Economics University of Zurich
This Version: February 13, 2006 First Version: October 1, 2003
∗The author especially thanks J´anos Mayer and Thorsten Hens for various interesting discussions and suggestions with regard to the subject, and Sara Silva for the development of the GPLAB toolbox that has been used to implement the reference Genetic Programming algorithm. He would also like to thank the following persons for their comments: Dana Bucher, Rosario Dell’Aquila, Daniel Egloff, Mark Schindler, Thomas Strauss, Andreas Tupak, Peter Woehrmann. The author welcomes comments and suggestions, including references to related papers he inadvertently overlooked.
†Correspondence Information: Mathias Bucher, Institute for Empirical Research in Economics,
Abstract
This paper investigates if in the equity market, technical indicator-based trading strategies that are created by evolutionary algorithms can generate a consistently higher return than the buy-and-hold benchmark index. The trading execution is designed to be as realistic as possible: In presence of generous transaction costs, a fully automated trading system executes trades using trailing buy stops, stop losses and an active liquidity management. The results are striking: Strictly out-of-sample and over a large period of time, the best strategy in the set of the evolved pareto-efficient strategies (return vs. complexity) generates an average daily return that is almost twice as high as the benchmark return. The risk of the best strategies (measured as conditional drawdown) is, at the same time, almost three times smaller than the one of the benchmark. These results hint at the fact that the equity market is not efficient in the sense of the rational equilibrium model. Two types of evolutionary algorithms are used to evolve trading strategies: Parse Tree Evolution (PARTE), a new algorithm presented in this paper for the first time, and Genetic Programming (GP) as the reference. Both algorithms achieve to develop highly profitable strategies.
JEL Classification Codes: C15, C53, C63, C88, G11
Key Words:
Trading Strategies, Trading Rules, Technical Indicators, Evolutionary Algorithms, Parse Tree Evolution, Genetic Programming, Grammatical Evolution, Reality Check, Conditional Draw-down, Code Bloat
1 Introduction
The use of technical indicators in trading strategies is widespread among traders in virtually all markets. Nevertheless, technical indicator based trading strategies have not received much attention from academia yet, especially not in realistic trading execution setups. The investiga-tions that have been made focus mostly on the profitability of single indicators or trading rules, not on technical indicator based strategies (see for example Fama and Blume (1966), Kaufman (1987), Sweeney (1988) Neftci (1991), Brock, Lakonishok and LeBaron (1992), Levich and Thomas (1993), Taylor (1994), Osler and Chang (1995), Sullivan, Timmermann and White (1999)). A notable exception is the work of Dempster and Jones (2001) and Dempster and Leemans (2004), who focus on technical indicator based trading systems in realistic settings.
In practice, most professionals who use technical indicators for trading do not rely on one single indicator, but combine several of them into strategies. This paper aims to investigate the profitability of such an approach, given a realistic trading procedure and -environment.
It shows that it is indeed possible to systematically outperform the buy-and-hold benchmark with trading strategies that are created by evolutionary algorithms and implemented with a systematic approach.
In an efficient market, however, it would be impossible to make profit with technical trading strategies over a long period of time: Efficient markets are populated by rational1traders only.
These traders would arbitrage the profit opportunities away that are created if prices are to a certain extend predictable, and the market would become efficient again. This paper gives thus empirical evidence against the Efficient Market Hypothesis.
To start the investigation, the issue of what strategies to test had to be resolved. The direct approach, i.e., a survey of trading strategies, is rather unpromising, as investment professionals are very unlikely to disclose their strategies (especially when they make money). Testing all possible combination of a set of indicators might be tempting, but would require an
unreal-1The concept of rational market participants has been introduced by Muth (1961) and extended by Lucas (1978). A market participant is rational if the subjective beliefs of the market participant correspond to the objective probabilities of the states of the economy.
istical amount of computational resources. Another possibility would be to use traditional search algorithms like gradient search. This approach is condemned to fail, though, as the corresponding search space is vast, unstructured and deceptive. Evolutionary algorithms like Genetic Algorithms (Holland (1975)) or Genetic Programming (Koza (1992)), however, are natural choice to explore search spaces with the above qualities, and some attempts have been undertaken to use them in the field of trading:
In the foreign currency exchange market, Neely, Weller and Dittmar (1997) use Genetic Programming to discover profitable technical trading rules. They report a strong evidence of out-of-sample excess return achieved by these rules. Oussaidene, Chopard, Pictet and Tomassini (1997) also report positive returns generated by their Genetic Programming based trading system. The high-frequency data trading system of Dempster and Jones (2001) uses Genetic Programming to emulate a trader who combines individual technical indicators to obtain buy- or sell signals. The best rule found by the system is modestly, but significantly profitable in the presence of realistic transaction costs. In the equity market, Allen and Kar-jalainen (1999) used Genetic Programming to search for optimal ex-ante technical trading rules on daily S&P500 data. They find no evidence that the return of these rules would, transaction cost adjusted, consistently outperform a buy-and-hold benchmark strategy. They conclude that the market is hence efficient in this sense. A broad overview of various other implemen-tations of Genetic Algorithms and Genetic Programming in computational finance is given by Chen (2002), including price forecasting, cash flow planning, option pricing and agent-based computational finance.
In this paper, two Evolutionary Algorithms are used to create technical indicator based trading strategies: Genetic Programming and a new algorithm proposed in this paper for the first time: Parse Tree Evolution.
Genetic Programming (GP) is a nonlinear parallel search algorithm inspired by natural evolution. Its solutions may be represented as parse trees/ decision trees and understood as programs to be executed. The length and complexity of the programs is not predefined. The
algorithm works in the following way: An initial population of random programs is created, each program representing a solution to the given problem (in the present case, this is a buy/ not buy signal). The population of programs is then evolved, using selection, mutation and crossover mechanisms. The selection mechanism chooses programs of the current generation to reproduce themselves and produce offspring. The fitter a program (in the present case the higher the return it generates), the greater its chance to be selected. During reproduction, mutations occur, i.e., modifications of parts of the program. Offspring is created by crossover, when parts of the parse tree of two parent programs are interchanged. Mutation and Crossover produce new programs that are potentially fitter. Selection, mutation and crossover are repeated over and over, leading to programs that solve the given problem better and better.
GP has been applied very successfully to a variety of search problems. It has a disadvan-tage, though: Its solutions tend to bloat, i.e., to increase uncontrollably in size due to neutral code bits called ’introns’. These introns contribute to the evolutionary survival of a program (as crossover, splitting an intron, does not reduce the quality of the program result). How-ever, introns slow down both the program execution and the search for optimal programs. As efficiency is crucial in the context of technical indicator based trading strategies (the strategy evaluation is very costly in terms of computational resources), the code bloat of Genetic Pro-gramming may be limiting the evolutionary success. Various attempts to avoid bloat have been undertaken, limiting, e.g., the maximum size or depth of the programs, including an explicit size element in the program fitness, or using multiobjective optimization for evolving compact GP programs by introducing the program size as a second, independent objective.
In this paper, I propose an alternative algorithm that does not suffer from bloat: Parse Tree Evolution (PARTE). PARTE allows for a gradual complexification of the program topology.
As its crossover mechanism does not invalidate resulting individuals, it makes the introns superfluous.
Both GP and PARTE are used to evolve technical indicator based trading strategies, emu-lating traders in their search for optimal trading strategies. The best strategies found by GP
and PARTE are compared in terms of
• Returns
• Risk (measured as the Conditional Drawdown CDD)
• Complexity
The trading procedure is designed to be as realistic as possible, comprising the following elements:
• To ensure the market liquidity of the traded stocks (and thus justify the hypothesis that traders are price takers), the simulations are based on the MSCI Switzerland data. This index encompasses the 35 biggest firms at the Swiss stock market
• Both the in-sample optimization data and the out-of-sample test data are chosen to contain all relevant market regimes
• Trading positions can be long only, i.e., no short sales are allowed.
• The trading execution is fully automated:
– Trailing buy stops generate positions in the portfolio – Stop losses liquidate positions
– An active money management restricts the downside risk
Data snooping is a serious issue when investigating technical trading rules and strategies.
To avoid this pitfall, four precautions are taken in this paper:
• To be eligible as inputs for the trading strategies, the technical trading rules have to make sense from a behavioral finance point of view.
• The time horizons of the technical rules are set using rules-of-thumb, i.e., one day, one week, two weeks, one month, three month, half a year as time spans. No rule parameters
• The Reality Check Bootstrap methodology of White (2000) is utilized to asses the full set of strategies that appear during the evolutionary process.
• The best strategies are tested in a large out-of-sample data set, containing more than twice the data points of the optimization sample.
The remainder of this paper details the aspects mentioned in the introduction. It is or-ganized as follows: Section 2 motivates the use of technical indicators as a basis for trading strategies and provides an overview of the indicators used in the simulations. Subsequently, it explains how to obtain buy signals from indicators using strategies, before treating the evo-lutionary creation of strategies with a brief discussion of the pros and cons associated to the different algorithms. Section 3 is dedicated to PARTE and its algorithmic details. Section4 documents the simulations and presents the obtained results. Section5concludes and indicates potential future directions of research.