For More Information Please Visit : T H E E N C Y C L O P E D I A O F T R A D I N G S T R A T E G I E S JEFFREY OWEN KATZ, Ph.D. DONNA 1. MCCORMICK T R A D E M A R K S A N D S E R V I C E M A R K S Company and product names associated with listings in this book should be con- sidered as trademarks or service marks of the company indicated. The use of a reg- istered trademark is not permitted for commercial purposes without the permission of the company named. In some cases, products of one company are offered by other companies and are presented in a number of different listings in this book. It is virtually impossible to identify every trademark or service mark for every prod- uct and every use, but we would like to highlight the following: Visual Basic, Visual C++, and Excel are trademarks of Microsoft Corp. NAG function library is a service mark of Numerical Algorithms Group, Ltd. Numerical Recipes in C (book and software) is a service mark of Numerical Recipes Software. TradeStation, SuperCharts, and SystemWriter Plus are trademarks of Omega Research. Evolver is a trademark of Palisade Corporation. Master Chartist is a trademark of Robert Slade, Inc. TS-Evolve and TradeCycles (MESA) are trademarks of Ruggiero Associates. Divergengine is a service mark of Ruggiero Associates. C++ Builder, Delphi, and Borland Database Engine are trademarks of Borland. CQC for Windows is a trademark of CQG, Inc. Metastock is a trademark of Eqnis International. technical analysis function library is a service mark of FM Labs. Excalibur is a trademark of Futures Truth. MATLAB is a trademark of The MathWorks, Inc. MESA96 is a trademark of Mesa. C..~. ONTENTS PREFACE xiii INTRODUCTION xv What Is a Complete Mechanical Trading System? - What Are Good Entries and Exits? * The Scientific Approach to System Development * Tools and Materials Needed for the Scientific Approach PART I Tools of the Trade Introduction 1 Chapter 1 Data 3 Types of Data * Data Time Frames * Data Quality Data Sources and Vendors l Chapter 2 Simulators 13 Types of Simulators * Programming the Simulator * Simulator Output @erformance summnry reports; trade-by-trade reports) * Simulator Perfomxmce (speed: capacity: power) l Reliability of Simulators - Choosing the Right Simulator * Simulators Used in This Book Chaoter 3 Optimizers and Optimization 29 What Optimizers Do * How Optimizers Are Used * ?Lpes of Optimization (implicit optimizers; brute force optimizers; user-guided optimization; genetic optimizers; optimization by simulated annealing; analytic optimizers; linearpmgrwnming) l How to Fail with Optimization (small samples: large fxmztneter sets; no veri~cation) . How to Succeed with O&mization (h-ge, representative samples; few rules andparameters; veriicatim @results) * Alternatives to Traditional Optimization * Optimizer Tools and Information * Which Optimizer Is forYou? Chapter 4 Statistics 51 Why Use Statistics to Evaluate Trading Systems? Sampling * Optimization and l Curve-Fitting Sample Size and Representativeness . Evaluating a System Statistically l * Example 1: Evaluating the Out-of-Sample Test (what ifthe distribution is not normal? what if there is serial dependence? what if the markets change?) l Example 2: Evaluating the In-Sample Tests * Interpreting the Example Statistics (optimization i-esults; verification results) l Other Statistical Techniques and Their Use (genetically evoJved systems; multiple regression; monte car10 simulations; out-of-sample testing; walk-forward testing) * Conclusion PART II The Study of Entries Introduction 71 What Constitutes a Good Entry? * Orders Used in Entries (stop orders; limit orders; market orders; selecting appropriate orders) * Entry Techniques Covered in This Book (breakouts and moving averages; oscillators; seasonality: lunar and solar phenomena: cycles and rhythms; neural networks; geneticaNy evolved entry rules) * Standardized Exits * Equalization of Dollar Volatility * Basic Test Portfolio and Platfcnm Chapter 5 Breakout Models 83 Kinds of Breakouts Characteristics of Breakouts . Testing Breakout Models l l Channel Breakout Entries (close only channel breakouts; highest higMowest low bnxzkouts) l Volatility Breakout Entries l Volatility Breakout Variations (long positions only; currencies only; adx tremififilter) . Summary Analyses (breakout types: entry orders; interactions; restrictions andjilters; analysis by market) * Conclusion l What Have We Lamed? Chapter 6 Moving Average Models 109 What is a Moving Average? - Purpose of a Moving Average * The Issue of Lag l Types of Moving Averages Types of Moving Average Entry Models Characteristics l l of Moving Average Entries Orders Used to Effect Entries * Test Methodology ’ l Tests of Trend-Following Models * Tests of Counter-Trend Models * Conclusion l What Have We Learned? ix Chapter 7 Oscillator-Based Entries 133 What Is an Oscillator? Kinds of Oscillators * Generating Entries with Oscillators * l Characteristics of Oscillator Entries . Test Methodology Test Results (teas of l overbought/oversold models; tests of signal line models; tests of divergence models; summary analyses) - Conclusion * What Have We Learned? Chapter S Seasonality 153 What Is Seasonality? Generating Seasonal Entries Characteristics of Seasonal l l Entries . Orders Used to Effect Seasonal Entries . Test Methodology . Test Results (test of the basic crossover model; tests of the basic momentum model: tests of the crossover model with con$mtion; tests of the C~SSOV~~ model with confirmation and inversions: summary analyses) * Conclusion * What Have We Learned? Chmter 9 Lunar and Solar Rhythms 179 Legitimacy or Lunacy? Lunar Cycles and Trading (generating lunar entries: lunar test l methodology; lunar test results; tests of the basic cmmo~er model; tests of the basic momentum model: tests of the cnx~mer model with confirmation; test.s of the crmmver model with confirmation and inversions; summary analyses; conclusion) * Solar Activity and Trading (generazing solar entries: solar test results: conclusion) * What Have We Learned? Chapter 10 Cycle-Based Entries 2Q3 Cycle Detection Using MESA Detecting Cycles Using Filter Banks (butterworth l jilters; wavelet-basedjilters) * Generating Cycle Entries Using Filter Banks * Characteristics of Cycle-Based Entries . Test Methodology . Test Results . Conclusion What Have We Learned? l Chapter 11 Neural Networks 227 What Are Neural Networks? (feed-forward neural networks) . Neural Networks in Trading Forecasting with Neural Networks Generating Entries with Neural l l Predictions . Reverse Slow %K Model (code for the reverse slow %k model: test methodology for the reverse slow %k model; training results for the reverse slow %k model) Turning Point Models (code for the turning point models; test methodology l for the turning point models; training resulrs for the turning point models) * Trading Results for All Models (@ading results for the reverse slow %k model: frading results for the bottom ruming point model; trading results for the top turning poinf model) * Summary Analyses Conclusion * What Have We Learned? l Chapter 12 Genetic Algorithms 257 What Are Genetic Algorithms? * Evolving Rule-Based Entry Models * Evolving an Entry Model @he rule remplares) * Test Methodology (code for evolving an entry model) Test Results (solutions evolved for long entries; solutions evolved for short l enrries; fesf results for the standard portfolio; market-by-market tesf resulrs: equify curves; the rules for rhe solurions tesred) * Conclusion * What Have We Learned? PART III The Study of Exits Introduction 281 The Importance of the Exit Goals of a Good Exit Strategy * Kinds of Exits l Employed in an Exit Strategy (money management exits; trailing exits; projir tnrgef exiW rime-based exits; volarilify airs: barrier exits; signal exits) * Considerations When Exiting the Market (gunning; trade-offs with prorecrive stops: slippage; conC?nian rrading: conclusion) * Testing Exit Strategies * Standard Entries for Testing Exits (the random entry model) Chaoter 13 The Standard Exit Strategy 293 What is the Standard Exit Strategy? * Characteristics of the Standard Exit * Purpose of Testing the SES Tests of the Original SES (test results) * Tests of the Modified SES l (test resulrs) * Conclusion - What Have We Learned? Chapter 14 Improvements on the Standard Exit 309 Purpose of the Tests Tests of the Fixed Stop and Profit Target * Tests of Dynamic l Stops (rest of the highest higWlowest low stop; fesf of the dynamic arr-based stop: fat of the modified exponential moving average dynamic stop) * Tests of the Profit Taget * Test of the Extended Time Limit - Market-By-Market Results for the Best Exit * Conclusion What Have We Learned? l P R E F A C E In this book is the knowledge needed to become a mc~re successful trader of com- modities. As a comprehensive reference and system developer’s guide, the book explains many popular techniques and puts them to the test, and explores innova- tive ways to take profits out of the market and to gain an extra edge. As well, the book provides better methods for controlling risk, and gives insight into which methods perform poorly and could devastate capital. Even the basics are covered: information on how to acquire and screen data, how to properly back-test systems using trading simulators, how to safely perform optimization, how to estimate and compensate for curve-fitting, and even how to assess the results using inferential statistics. This book demonstrates why the surest way to success in trading is through use of a good, mechanized trading system. For all but a few traders, system trading yields mm-e profitable results than discretionary trading. Discretionary trading involves subjective decisions that fre- quently become emotional and lead to losses. Affect, uncertainty, greed, and fear easily displace reason and knowledge as the driving forces behind the trades. Moreover, it is hard to test and verify a discretionary trading model. System- based trading, in contrast, is objective. Emotions are out of the picture. Through programmed logic and assumptions, mechanized systems express the trader’s reason and knowledge. Best of all, such systems are easily tested: Bad systems can be rejected or modified, and good cntes can be improved. This book contains solid information that can be of great help when designing, building, and testing a profitable mechanical trading system. While the emphasis is on an in-depth, critical analysis of the various factors purported to contribute to winning systems, the essential elements of a complete, mechanical trading system are also dissected and explained. To be complete, all mechanical trading systems must have an entry method and an exit method. The entry method must detect opportunities to enter the mar- ket at points that are likely to yield trades with a good risk-to-reward ratio. The exit method must protect against excessive loss of capital when a trade goes wrong or when the market turns, as well as effectively capture profits when the market moves favorably. A considerable amount of space is devoted to the systematic back-testing and evaluation of exit systems, methods, and strategies. Even the trader who already has a trading strategy or system that provides acceptable exits is likely to discover something that can be used to improve the system, increase profits, and reduce risk exposure. Also included in these pages are trading simulations on entire pqrtfolios of tradables. As is demonstrated, running analyses on portfolios is straightforward, if not easy to accomplish. The ease of computing equity growth curves, maximum drawdowns, risk-to-reward ratios, returns on accounts, numbers of trades, and all xiv PREFACE the other related kinds of information useful in assessing a trading system on a whole portfolio of commodities or stocks at once is made evident. The process of conducting portfolio-wide walk-forward and other forms of testing and optimiza- tion is also described. For example, instruction is provided on how to search for a set of parameters that, when plugged into a system used to trade each of a set of commodities, yields the best total net profit with the lowest drawdown (or perhaps the best Sharpe Ratio, or any other measure of portfolio performance desired) for that entire set of commodities. Small institutional traders (CTAs) wishing to run a system on multiple tradables, as a means of diversification, risk reduction, and liq- uidity enhancement, should find this discussion especially useful. Finally, to keep all aspects of the systems and components being tested objective and completely mechanical, we have drawn upon our academic and sci- entific research backgrounds to apply the scientific method to the study of entry and exit techniques. In addition, when appropriate, statistics are used to assess the significance of the results of the investigations. This approach should provide the most rigorous information possible about what constitutes a valid and useful com- ponent in a successful trading strategy. So that everyone will benefit from the investigations, the exact logic behind every entry or exit strategy is discussed in detail. For those wishing to replicate and expand the studies contained herein, extensive source code is also provided in the text, as well as on a CD-ROM (see offer at back of book). Since a basic trading system is always composed of two components, this book naturally includes the following two parts: “The Study of Entries” and “The Study of Exits.” Discussions of particular technologies that may be used in gener- ating entries or exits, e.g., neural networks, are handled within the context of devel- oping particular entry or exit strategies. The “Introduction” contains lessons on the fundamental issues surrounding the implementation of the scientific approach to trading system development. The first part of this book, “Tools of the Trade,” con- tains basic information, necessary for all system traders. The “Conclusion” pro- vides a summary of the research findings, with suggestions on how to best apply the knowledge and for future research. The ‘Appendix” contains references and suggested reading. Finally, we would like to point out that this book is a continuation and elab- oration of a series of articles we published as Contributing Writers to Technical Analysis of Stocks and Commodities from 1996, onward. Jeffrey Owen Katz, Ph.D., and Donna L. McCormick