Automated Foreign Exchange Trading System

Total Page:16

File Type:pdf, Size:1020Kb

Automated Foreign Exchange Trading System 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 .....................................................
Recommended publications
  • Forecasting Direction of Exchange Rate Fluctuations with Two Dimensional Patterns and Currency Strength
    FORECASTING DIRECTION OF EXCHANGE RATE FLUCTUATIONS WITH TWO DIMENSIONAL PATTERNS AND CURRENCY STRENGTH A THESIS SUBMITTED TO THE GRADUATE SCHOOL OF NATURAL AND APPLIED SCIENCES OF MIDDLE EAST TECHNICAL UNIVERSITY BY MUSTAFA ONUR ÖZORHAN IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF DOCTOR OF PILOSOPHY IN COMPUTER ENGINEERING MAY 2017 Approval of the thesis: FORECASTING DIRECTION OF EXCHANGE RATE FLUCTUATIONS WITH TWO DIMENSIONAL PATTERNS AND CURRENCY STRENGTH submitted by MUSTAFA ONUR ÖZORHAN in partial fulfillment of the requirements for the degree of Doctor of Philosophy in Computer Engineering Department, Middle East Technical University by, Prof. Dr. Gülbin Dural Ünver _______________ Dean, Graduate School of Natural and Applied Sciences Prof. Dr. Adnan Yazıcı _______________ Head of Department, Computer Engineering Prof. Dr. İsmail Hakkı Toroslu _______________ Supervisor, Computer Engineering Department, METU Examining Committee Members: Prof. Dr. Tolga Can _______________ Computer Engineering Department, METU Prof. Dr. İsmail Hakkı Toroslu _______________ Computer Engineering Department, METU Assoc. Prof. Dr. Cem İyigün _______________ Industrial Engineering Department, METU Assoc. Prof. Dr. Tansel Özyer _______________ Computer Engineering Department, TOBB University of Economics and Technology Assist. Prof. Dr. Murat Özbayoğlu _______________ Computer Engineering Department, TOBB University of Economics and Technology Date: ___24.05.2017___ I hereby declare that all information in this document has been obtained and presented in accordance with academic rules and ethical conduct. I also declare that, as required by these rules and conduct, I have fully cited and referenced all material and results that are not original to this work. Name, Last name: MUSTAFA ONUR ÖZORHAN Signature: iv ABSTRACT FORECASTING DIRECTION OF EXCHANGE RATE FLUCTUATIONS WITH TWO DIMENSIONAL PATTERNS AND CURRENCY STRENGTH Özorhan, Mustafa Onur Ph.D., Department of Computer Engineering Supervisor: Prof.
    [Show full text]
  • Technical Analysis Masterclass
    TRADING: TECHNICAL ANALYSIS MASTERCLASS - Master The Financial Markets – Rolf Schlotmann & Moritz Czubatinski Copyright © 2019, Rolf Schlotmann, Moritz Czubatinski, Quantum Trade Solutions GmbH All rights reserved, including those of reprinting of extracts, photomechanical and electronical reproduction and translation. Any duplication, reproduction and publication outside the provisions of copyright law (Urheberrechtsgesetz) is not permitted as a whole or in part without the prior written consent of the author. This work is not intended to give specific investment recommendations and merely provides general guidance, exemplary illustrations and personal views. Author, publisher and cited sources are not liable for any loss or other consequences arising from the implementation of their thoughts and views. Any liability is excluded. The advice and information published in this book has been carefully prepared and reviewed by the author. Anyhow, a guarantee or other responsibility for their accuracy, completeness and timeliness cannot be given. In particular, it should be noted that all speculative investment transactions involve a significant risk of loss and are not suitable for all investors. It is strongly recommended not to rely solely on this book, but to conduct own investigations and analyses and, if necessary, to obtain advice from financial advisors, tax advisors and lawyers before making an investment decision. Company identity Quantum Trade Solutions GmbH Jahnstrasse 43 63075 Offenbach Germany Chairmen: Schlotmann, Rolf and Czubatinski, Moritz Publication date: 19.02.2019 1st version Financial charts have been obtained through www.tradingview.com Foreword Introduction 1. What is trading? 1.1 The profit potential 1.2 Decision-making 1.3 Short-term vs. long-term trading 2.
    [Show full text]
  • An Interview with John Bollinger
    ® AIQ Opening BellMonthly IN THIS ISSUE VOL. 6 ISSUE 2 FEBRUARY 1997 TRADING TECHNIQUES Feature John Bollinger discusses his Bollinger Bands .................. 1 AN INTERVIEW WITH JOHN BOLLINGER Se ctions account program, what percent of the By David Vomund investments are in equities and what is Price Volume Divergence your average holding period? Report .................................. 5 his month we are pleased to JB: We are primarily equity Market Review ..................... 8 present an interview with John investors. We dont buy any futures. Data Maintenance ............... 8 Bollinger, a keynote speaker at Our growth model is currently allo- Tour March seminar in Dallas. Mr. cated approximately 60% to the stock Bollinger is market, 20% to the president of bond market, and Bollinger Capital 20% to the interna- Management. He tional stock mar- provides money ket. We are management primarily interme- services and diate term traders. publishes the Our research tends Capital Growth to center on a Letter. He is best holding period of known for his three to six months Bollinger Bands, with most of the which is a feature emphasis on six in TradingExpert. months. However, For information on that doesnt Bollinger Capital preclude us from The Opening Bell Monthly Managements John Bollinger, CFA, CMT taking advantage is a publication of products and of short term AIQ Incorporated services, call 310-798-8855 or write to opportunities, for example when we see David Vomund, Chief Analyst P.O. Box 3358, Manhattan Beach, CA an attractive technical non-confirma- P.O. Box 7530 90266. Send e-mail to tion. Incline Village, Nevada 89452 [email protected].
    [Show full text]
  • Investing with Bollinger Bands
    Investing with Bollinger Bands This article was written some years ago, but is very relevant to today. The charts used to illustrate the text are now somewhat dated, but still relevant for the present purpose of teaching a technique. As moving averages became more popular, some analysts noticed that when prices were moving upward, they had a tendency to rise only so far above the moving average. When prices were falling they tended to fall only so far below the moving average. How far they rose or fell seemed to vary from stock to stock and also from time to time. However, the tendency was so consistent that it could be useful to both traders and investors. These early analysts hit on the idea of drawing lines a certain percentage of the moving average above and below the moving average line. They selected the percentage stock-by-stock so that it seemed to catch most of the price action on the chart, typically 90% or more of the price action. GWT - GWA INTERNATIONAL > -2 to 291 D @ D 020103-070604 320 MOV AVS 22(0) 5 band 310 300 290 280 270 260 250 240 230 JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC JAN FEB MAR APR MAY JUN 03 04 Chart 1: Daily Line Chart of GWA International with a 22-day Moving Average and 5% Bands The result was something like Chart 1, where we have a daily line chart, on which is drawn a 22-day moving average, with 5% bands above and below it.
    [Show full text]
  • The Cycle Trading Pattern Manual 2 Copyright © Walter Bressert, Inc
    TIMING IS EVERYTHING …And the use of time cycles can greatly improve the accuracy and success of your trading and/or system. There is no magic oscillator or indicator that will bring you THE CYCLE success in the markets. Knowledge of trading techniques and tools to improve TIMING and determine TREND is the key to low TRADING risk high probability trades that can bring you success. Knowledge, self-discipline and persistence are the true keys to PATTERN success in trading. Over time you will develop a trading style that fits your personality and trading skills. There are many tools to MANUAL help improve your trading, but only cycles will allow you to add By Walter Bressert the element of TIME into your trading. www.walterbressert.com Simple buy and sell signals do not consider the whole picture. By combining mechanical trading signals with daily and weekly cycles (or two intra-day time periods and cycles, such as a 45- minute and 180-minute, or a 5-minutes and 20-minute), retracements, trend Indicators and trendlines into Cycle Trading Patterns, you can greatly improve your accuracy and odds of making money on a trade or with a system. The following charts and trading concepts are based on trading the long side of a market. The same techniques and concepts work in mirror image fashion for trading the short side TABLE OF CONTENTS IDENTIFYING CYCLE TOPS AND BOTTOMS USING OSCILLATORS 2 Detrending Takes the Mystery Out of Cycles 3 Oscillators Show Cycle Tops and Bottoms 5 OSCILLATOR/PRICE PATTERNS GENERATE MECHANICAL TRADING SIGNALS 6 Detrended
    [Show full text]
  • Technical-Analysis-Bloomberg.Pdf
    TECHNICAL ANALYSIS Handbook 2003 Bloomberg L.P. All rights reserved. 1 There are two principles of analysis used to forecast price movements in the financial markets -- fundamental analysis and technical analysis. Fundamental analysis, depending on the market being analyzed, can deal with economic factors that focus mainly on supply and demand (commodities) or valuing a company based upon its financial strength (equities). Fundamental analysis helps to determine what to buy or sell. Technical analysis is solely the study of market, or price action through the use of graphs and charts. Technical analysis helps to determine when to buy and sell. Technical analysis has been used for thousands of years and can be applied to any market, an advantage over fundamental analysis. Most advocates of technical analysis, also called technicians, believe it is very likely for an investor to overlook some piece of fundamental information that could substantially affect the market. This fact, the technician believes, discourages the sole use of fundamental analysis. Technicians believe that the study of market action will tell all; that each and every fundamental aspect will be revealed through market action. Market action includes three principal sources of information available to the technician -- price, volume, and open interest. Technical analysis is based upon three main premises; 1) Market action discounts everything; 2) Prices move in trends; and 3) History repeats itself. This manual was designed to help introduce the technical indicators that are available on The Bloomberg Professional Service. Each technical indicator is presented using the suggested settings developed by the creator, but can be altered to reflect the users’ preference.
    [Show full text]
  • Technical Analysis: Technical Indicators
    Chapter 2.3 Technical Analysis: Technical Indicators 0 TECHNICAL ANALYSIS: TECHNICAL INDICATORS Charts always have a story to tell. However, from time to time those charts may be speaking a language you do not understand and you may need some help from an interpreter. Technical indicators are the interpreters of the Forex market. They look at price information and translate it into simple, easy-to-read signals that can help you determine when to buy and when to sell a currency pair. Technical indicators are based on mathematical equations that produce a value that is then plotted on your chart. For example, a moving average calculates the average price of a currency pair in the past and plots a point on your chart. As your currency chart moves forward, the moving average plots new points based on the updated price information it has. Ultimately, the moving average gives you a smooth indication of which direction the currency pair is moving. 1 2 Each technical indicator provides unique information. You will find you will naturally gravitate toward specific technical indicators based on your TRENDING INDICATORS trading personality, but it is important to become familiar with all of the Trending indicators, as their name suggests, identify and follow the trend technical indicators at your disposal. of a currency pair. Forex traders make most of their money when currency pairs are trending. It is therefore crucial for you to be able to determine You should also be aware of the one weakness associated with technical when a currency pair is trending and when it is consolidating.
    [Show full text]
  • Timeframeset
    QuantShare Programming Language Table of contents 1. QuantShare Language 1.1 Application Info 1.1.1 NbGroups 1.1.2 NbIndexes 1.1.3 NbIndustries 1.1.4 NbInGroup 1.1.5 NbInIndex 1.1.6 NbInIndustry 1.1.7 NbInMarket 1.1.8 NbInSector 1.1.9 NbMarkets 1.1.10 NbSectors 1.2 Candlestick Pattern 1.2.1 Cdl2crows (0) 1.2.2 Cdl2crows (1) 1.2.3 Cdl3blackcrows (0) 1.2.4 Cdl3blackcrows (1) 1.2.5 Cdl3inside (0) 1.2.6 Cdl3inside (1) 1.2.7 Cdl3linestrike (0) 1.2.8 Cdl3linestrike (1) 1.2.9 Cdl3outside (0) 1.2.10 Cdl3outside (1) 1.2.11 Cdl3staRsinsouth (0) 1.2.12 Cdl3staRsinsouth (1) 1.2.13 Cdl3whitesoldiers (0) 1.2.14 Cdl3whitesoldiers (1) 1.2.15 CdlAbandonedbaby (0) 1.2.16 CdlAbandonedbaby (1) 1.2.17 CdlAdvanceblock (0) 1.2.18 CdlAdvanceblock (1) 1.2.19 CdlBelthold (0) 1.2.20 CdlBelthold (1) 1.2.21 CdlBreakaway (0) 1.2.22 CdlBreakaway (1) 1.2.23 CdlClosingmarubozu (0) 1.2.24 CdlClosingmarubozu (1) 1.2.25 CdlConcealbabyswall (0) 1.2.26 CdlConcealbabyswall (1) 1.2.27 CdlCounterattack (0) 1.2.28 CdlCounterattack (1) 1.2.29 CdlDarkcloudcover (0) 1.2.30 CdlDarkcloudcover (1) 1.2.31 CdlDoji (0) 1.2.32 CdlDoji (1) 1.2.33 CdlDojistar (0) 1.2.34 CdlDojistar (1) 1.2.35 CdlDragonflydoji (0) 1.2.36 CdlDragonflydoji (1) 1.2.37 CdlEngulfing (0) 1.2.38 CdlEngulfing (1) 1.2.39 CdlEveningdojistar (0) 1.2.40 CdlEveningdojistar (1) 1.2.41 CdlEveningstar (0) 1.2.42 CdlEveningstar (1) 1.2.43 CdlGapsidesidewhite (0) 1.2.44 CdlGapsidesidewhite (1) 1.2.45 CdlGravestonedoji (0) 1.2.46 CdlGravestonedoji (1) 1.2.47 CdlHammer (0) 1.2.48 CdlHammer (1) 1.2.49 CdlHangingman (0) 1.2.50
    [Show full text]
  • Application of Machine Learning in High Frequency Trading of Stocks
    International Journal of Scientific & Engineering Research Volume 10, Issue 5, May-2019 1592 ISSN 2229-5518 Application of Machine Learning in High Frequency Trading of Stocks Obi Bertrand Obi Worldquant University 201 St. Charles Avenue, Suite 2500 New Orleans, LA 70170, USA [email protected] Abstract Algorithmic trading strategies have traditionally been centered on follwing the market trends and the use of technical indicators. Over the years High Frequency algorithmic Trading has been left only in the hands of institutional players with deep pockets and lots of assets under management, despite huge returns involved. In this project webuilt trading strategies by applying Machine Learning models to technical indicators based on High Frequency Stock data. The result is an automated trading system which when applied to any stock could generate returns which are ten times higher than the market returns without significant increase in volatility. With advancement in technology High Frequency Algorithmic trading can be undertaken even by individuals or retail traders with moderate initial investment and technical skills. Keywords:Machine Lerning; Prediction of stock prices movements; Classification reports; Algorithmic trading; High frequency trading; Key performace indicators IJSER 1. Introduction Not too long ago, Algorithmic Trading was only available for institutional players with deep pockets and lots of assets under management. Recent developments in the areas of open source, open data, cloud computing and storage as well as online trading platforms have leveled the playing field for smaller institutions and individual traders, making it possible to venture in this fascinating discipline with only a modern notebook and an Internet connection. Nowadays, Python and its eco-system of powerful packages is the technology platform of choice for algorithmic trading.
    [Show full text]
  • Trading Indicator Blueprint
    Effective use of the most popular trading indicators www.netpicks.com This information is prepared solely for general information and educational purposes and is not a solicitation to buy or sell securities or financial products mentions in the content, nor a recommendation to participate in any particular trading strategy. Please consult your broker for trading advice. The author is not a broker on a licensed investment advisor and is not licensed to give trading advice or any sort, nor make specific trading recommendations. Entire risk disclosure can be found at www.sec.gov Whether you are a new or experienced trader, you are probably familiar with the multitude of trading indicators available. I know when I started trading almost a decade ago, virtually every indicator ended up on my charts at one time or another. And it was frustrating! You may be able to relate to: Always searching for the “perfect” combination of indicators for high probability trading setups. Tweaking inputs over and over again trying to “fit” the indicator to past price to match the perfect trade. Looking to “catch the turn” to avoid adverse excursion and to take every pip or tick the market is willing to give. Adverse Excursion The amount of loss an open trade takes before completion with profit or a loss. The hard truth is that PERFECTION does not exist in trading. 1 Neither does the perfect indicator or perfect setting. You can use indicators as part of an overall trading system and although that requires a lot of work and testing, it can be done! So where do you start? The majority of indicators use price in their mathematical calculations before plotting on your chart.
    [Show full text]
  • The-Power-Of-Divergence.Pdf
    Trading with the Trendlines The Power of Divergence DAVID CARLI ii Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in foreign exchange, you should carefully consider your investment objectives, level of experience, and risk appetite. No information or opinion contained in this e-Book should be taken as a solicitation or offer to buy or sell any currency, or other financial instruments or services. Past performance is no indication or guarantee of future performance. Copyright © Fifth edition April 2020 by David Carli. All rights reserved. This book or any portion thereof may not be reproduced or used in any manner whatsoever without the express written permission of the publisher except for the use of brief quotations in a book review. First Printing: 2016 ISBN: 9798645292959 Website: www.tradingwithdavid.com E-mail: [email protected] iv DEDICATION My parents, who made me the person I am today. Introduction – About the Author 1 Introduction – About TradingView 3 Introduction – Preface 5 Chapter 1 – Chart 7 Chapter 2 – Some Technical Analysis 17 Chapter 3 – Commodity Channel Index 35 Chapter 4 – The Strategy 40 Chapter 6 – Money Management 64 Chapter 7 – Final Comments 69 Appendix A – Web Resources 74 David Carli is an Italian trader and independent financial analyst. He completed his studies at the University of Pisa, and he has released several successful books about trading. It is his success and knowledge that David wishes to pass on to other potential traders, helping them to avoid mistakes and succeed in the finance and investment markets.
    [Show full text]
  • My Favourite Trading Strategy Commodity Channel Index
    My Favourite Trading Strategy Commodity Channel Index • Donald Lambert 1980 • Identify new trends or warns of volatility • Developed to identify cyclical turns in commodities • CCI measures a current price level vs. an average level over time • CCI is high when price is above average CCI Calculation • CCI = (Typical Price - 20-period SMA of TP) Divided by (.015 x Mean Deviation) • Typical Price (TP) = (High + Low + Close)/3 • Constant = .015 Commodity Channel Index • Lambert set the constant at .015 to ensure that approximately 70 to 80 percent of CCI values would fall between -100 and +100. • The smaller the CCI period (look back period), the smaller the number of values between -100 and +100. Commodity Channel Index 20 period Commodity Channel Index 40 period CCI Interpretation • A coincidental indicator – surges above 100 show strong price action and could signal the start of an uptrend. • A leading indicator – overbought or oversold conditions with bullish and bearish divergence. CCI - Coincidental CCI - leading Stochastic Oscillator • A momentum indicator developed by George Lane in the 1950’s. • Does NOT follow price or volume. • Follows SPEED or MOMENTUM of PRICE. • As a rule, momentum changes direction before price. Fast Stochastic • %K = (Current Close - Lowest Low) Divided (Highest High - Lowest Low) X 100 • %D = 3-day SMA of %K (trigger line) Fast Stochastic Slow Stochastic • Slow %K = Fast %K smoothed with 3-period SMA • Slow %D = 3-period SMA of Slow %K • I use 8-period SMA and 4-period SMA of Slow %K Slow Stochastic Slow Stochastic Interpretation • Overbought – above 80 • Oversold – below 20 • Ignore Overbought/Oversold when trending.
    [Show full text]