Automated Foreign Exchange Trading System
Total Page:16
File Type:pdf, Size:1020Kb
Automated Foreign Exchange Trading System An Interactive Qualifying Project Report Submitted to the Faculty of WORCESTER POLYTECHNIC INSTITUTE in partial fulfillment of the requirement for the Degree of Bachelor of Science Submitted on May 23, 2011 Submitted to: Project Advisor: Professor Michael J. Radzicki, Social Science & Policy Studies, WPI Submitted by: Jaymin R. Mehta, Computer Science Marcus D. Menghini, Robotics Engineering Daniel A. Sarafconn, Robotics Engineering Abstract We sought to use the TradeStation trading platform to develop an automated strategy to trade in the foreign exchange, or currency markets. Meeting with our advisor, and conducting independent research, we evaluated various trading methods and strategies. We then developed indicators and strategies in EasyLanguage, TradeStation’s proprietary programming language, testing and evaluating which methods were successful. Finally, we developed a strategy, which incorporated concepts from several models, that trades successfully in the forex market. i Authorship The development of the automated foreign exchange trading strategy and the written report were created with equal contributions from Jaymin R. Mehta, Marcus D. Menghini, and Daniel A. Sarafconn. ii Acknowledgements We would like to thank our project advisor, Professor Michael J. Radzicki. We greatly appreciated his guidance and support throughout our project. iii Table of Contents Abstract ............................................................................................................................................ i Authorship....................................................................................................................................... ii Acknowledgements ........................................................................................................................ iii Table of Figures ............................................................................................................................. vi Executive Summary ...................................................................................................................... vii 1. Introduction ................................................................................................................................. 1 2. Background ................................................................................................................................. 1 2.1 The Foreign Exchange Market (forex) ................................................................................. 1 2.2 TradeStation Platform and Features...................................................................................... 4 2.2.1 Back -testing .................................................................................................................. 4 2.2.2 Optimization .................................................................................................................. 5 2.2.3 Walk Forward Cluster Analysis ..................................................................................... 5 2.2.4 EasyLanguage ................................................................................................................ 5 2.3 Market Types and Strategies ................................................................................................. 6 2.3.1 Trending ......................................................................................................................... 7 2.3.2 Directionless .................................................................................................................. 8 2.3.3 Volatile ........................................................................................................................... 9 2.4 Indicators............................................................................................................................. 10 2.4.1 Simple Moving Average .............................................................................................. 10 2.4.2 Bollinger Bands ........................................................................................................... 11 2.4.3 Keltner Channel ........................................................................................................... 12 2.4.4 Commodity Channel Index .......................................................................................... 13 2.4.5 Volume Oscillator ........................................................................................................ 14 2.4.6 Volume Ratio ............................................................................................................... 15 3. Procedure .................................................................................................................................. 15 3.1 Currencies ........................................................................................................................... 16 3.2 Trading Strategies ............................................................................................................... 16 3.2.1 Double Moving Average Cross ................................................................................... 17 3.2.2 Bollinger Band/ Keltner Channel Counter-Trend ........................................................ 17 3.2.3 CCI Counter-Trend ...................................................................................................... 18 3.2.4 CCI and Trade Volume Breakout ................................................................................ 18 4. Results ....................................................................................................................................... 18 4.1 Double Moving Average Cross (DMAC) ........................................................................... 19 iv 4.2 Bollinger Band/ Keltner Channel Counter-Trend ............................................................... 20 4.3 CCI Counter-Trend ............................................................................................................. 20 4.4 CCI & Volume Breakout .................................................................................................... 21 5. Conclusions ............................................................................................................................... 21 References ........................................................................................................................................ I Appendix A: DMAC Strategy Code ............................................................................................... II Appendix B: Bollinger/ Keltner Counter-Trend Strategy Code .................................................. III Appendix C: CCI Counter-Trend Strategy Code ........................................................................... V Appendix D: CCI and Trade Volume Breakout Strategy Code .................................................... VI Appendix E: DMAC Performance Report ................................................................................. VIII Appendix F: Bollinger/ Keltner Strategy Performance Report .................................................... XII Appendix G: CCI Counter-Trend Performance Report ............................................................. XVI Appendix H: CCI & Volume Breakout Strategy Performance Report ........................................ XX Appendix I: Strategy Analysis ................................................................................................ XXIV v Table of Figures Figure 1: An example of a candlestick graph, showing fifteen minute bars. .................................. 4 Figure 2: Trending Market with Moving Averages ........................................................................ 7 Figure 3: Directionless Market ....................................................................................................... 8 Figure 4: Volatile Market................................................................................................................ 9 Figure 5: Simple Moving Average ............................................................................................... 10 Figure 6: Bollinger Bands ............................................................................................................. 11 Figure 7: Keltner Channel ............................................................................................................. 12 Figure 8: CCI Average .................................................................................................................. 13 Figure 9: Volume Oscillator ......................................................................................................... 14 Figure 10: Volume Ratio .............................................................................................................. 15 Figure 11: Gapping ....................................................................................................................... 17 Figure 12: Analysis of Trading Strategies .................................................................................... 19 Figure 13: DMAC Strategy Performance Report ......................................................................... 19 Figure 14: Bollinger/ Keltner Strategy Performance Report ........................................................ 20 Figure 15: CCI Counter-Trend Strategy Performance Report .....................................................