Automated Trading Software for Foreign Exchange

Total Page:16

File Type:pdf, Size:1020Kb

Automated Trading Software for Foreign Exchange Saul Stockhus AUTOMATED TRADING SOFTWARE FOR FOREIGN EXCHANGE Bachelor’s Thesis Information Technology May 2011 DESCRIPTION Date of the bachelor's thesis May 20, 2011 Author(s) Degree programme and option Saul Stockhus Information Technology Name of the bachelor's thesis Automated trading software for Foreign Exchange Abstract The Foreign Exchange market is the largest financial market in the world. It is used by banks, gov- ernments, corporations, hedge funds and other institutions for a number of purposes, such as curren- cy conversion, hedging and speculation. Due to advances in computing, financial data that could pre- viously only be analyzed using charts or calculated manually can now be run through extensive ana- lyses using special algorithms in order to predict the future. The aim of this study is to research trading in the Foreign Exchange market and to implement an au- tomated trading strategy using a suitable programming language and successfully test it with real market data. Of particular interest was the prospect of discovering new trading methods and tools. During the course of this study, different types of trading strategies as well as new chart types were developed for the NinjaTrader platform. The strategies were tested using historic exchange rates as well as captured live rates. Choosing the type of strategy, trading platform or broker, as well as other considerations such as real life implementation is discussed. The study is useful particularly to IT and business students interested in the currency markets and automated trading in general. The study gives guidelines on strategy development and gives room for improvement in the future. Subject headings, (keywords) Foreign Exchange, forex, price analysis, automated trading, algorithmic trading, NinjaTrader Pages Language URN 42 pages + appendices 2 pages English http://www.urn.fi/URN:NBN:f i:amk-201105208891 Remarks, notes on appendices Tutor Employer of the bachelor's thesis Reijo Vuohelainen Mikkeli University of Applied Sciences CONTENTS 1 INTRODUCTION................................................................................................ 1 1 FOREIGN EXCHANGE ..................................................................................... 3 1.1 Overview ..................................................................................................... 3 1.2 Participants ................................................................................................. 4 1.3 Financial instruments .................................................................................. 6 2 TRADING CONCEPTS ...................................................................................... 6 2.1 Trading with currency pairs ........................................................................ 6 2.2 Types of brokers ....................................................................................... 11 2.3 Terminology ............................................................................................. 12 3 ALGORITHMIC TRADING ............................................................................. 14 3.1 Overview ................................................................................................... 14 3.2 Technical Analysis .................................................................................... 14 3.3 Sample strategies ...................................................................................... 17 3.4 Software .................................................................................................... 18 3.5 Communication between platform and broker ......................................... 22 4 PROJECT ........................................................................................................... 23 4.1 Project overview ....................................................................................... 23 4.2 Considerations .......................................................................................... 23 4.3 Developed code ........................................................................................ 31 4.3.1 Strategies ..................................................................................... 31 4.3.2 Bar types ...................................................................................... 33 4.4 Problems ................................................................................................... 35 4.5 Results....................................................................................................... 36 4.6 Real life implementation ........................................................................... 40 5 CONCLUSION .................................................................................................. 40 BIBLIOGRAPHY ........................................................................................................ 42 APPENDICES LIST OF FIGURES Figure 1. Example of a currency pair chart ................................................................................ 7 Figure 2. Market Depth window of the ECN broker MB Trading, showing bids on the left and asks on the right ........................................................................................................................ 12 Figure 3. Bar properties in NinjaTrader ................................................................................... 15 Figure 4. Candlesticks .............................................................................................................. 15 Figure 5. OHLC bar .................................................................................................................. 16 Figure 6. Candlestick ................................................................................................................ 16 Figure 7. Line chart - example of an up trend .......................................................................... 16 Figure 8. MetaTrader 4 main window ...................................................................................... 19 Figure 9. MetaEditor programming environment .................................................................... 20 Figure 10. NinjaTrader 6.5 main window ................................................................................ 21 Figure 11. NinjaTrader script editor ......................................................................................... 22 Figure 12. Market Analyzer window with a custom indicator showing the current spread ..... 25 Figure 13. Range bar chart – a built-in bar type in NinjaTrader .............................................. 27 Figure 14. Renko bar behavior ................................................................................................. 28 Figure 15. New bar type behavior ............................................................................................ 28 Figure 16. Output window used for debugging ........................................................................ 31 Figure 17. Tracker bars ............................................................................................................. 34 Figure 18. 60 minute, Tracker and Neko bars compared ......................................................... 35 Figure 19. Strategy #1 - Cumulated profit ................................................................................ 37 Figure 20. Strategy #1, Profit/Loss Report. Green triangles indicate winning trades and red triangles losing trades. .............................................................................................................. 38 LIST OF TABLES Table 1. Foreign Exchange trading sessions .............................................................................. 3 Table 2. Top 10 currency traders - % of overall volume, May 2010 [Euromoney] ................... 4 Table 3. ISO 4271 codes and currency names for major currencies .......................................... 7 Table 4. Lot names and their sizes ............................................................................................. 8 Table 5. Spread cost compared to bar range. The chosen spread is 3 pips. ............................. 29 Table 6. Mixed mode operation ................................................................................................ 32 Table 7. Account performance ................................................................................................. 38 1 1 INTRODUCTION The Foreign Exchange market today is the largest financial market in the world and is an im- portant tool for international trade. The market allows currency to be bought and sold and in the process the market determines the relative values of currencies against each other. Busi- nesses use it to pay their workers, governments try to control the exchange rates of their cur- rency in order to maintain the economy and investors convert currency back and forth in order to invest and reap the profits. The Foreign Exchange did not always have the importance it has today. When the value of a currency was still tied to real commodities, such as gold and silver, there was little risk that holding a currency would affect profits. Foreign Exchange only had a minor part in finance until the late 1960’s, when governments with the largest economies agreed to part with the established Bretton Woods fixed-rate system and decided to allow trading to determine cur- rency rates, resulting in a floating exchange rate regime. Uncertainty about exchange rates
Recommended publications
  • Trading Platform Requirements Trading Platform Requirements
    Trading Platform requirements Trading Platform requirements MetaTrader 4 MetaTrader 4, PC specifications: The Client Terminal can operate under Microsoft Windows 7/8/10. A processor that supports SSE2 instruction sets is required for operating as well. Other hardware requirements depend on terms of using the terminal – load from running MQL4 applications, number of active instruments and charts, etc. MetaTrader 4, Android specification: To install MT4 on the gadget with Android OS, the Android 5.0 version or a higher one is required. The MT4 Application for Android requires 9.6 MB of free space on your phone. MetaTrader 4, IOS specification: To install MT4 on the gadget with iOS, the iOS 9.0 version or a higher one is required. The MT4 Application for iOS requires 22.7 MB of free space on your phone. 2 Trading Platform requirements cTrader cTrader, PC requirements: Minimum Recommended Processor Dual-Core CPU Dual-Core CPU Memory 2GB 4GB Operating System * Windows 7 and higher * Windows latest version * MacOS 10.13 High Sierra or * MacOS latest version higher Internet The stable connection from 50 The stable connection from 100 Connection kB per second or faster. kB per second or faster. Screen Resolution 1280x800 13- to 15-inch screen standard ratio: 1400×1050 13- to 15-inch screen widescreen: 1280x800 17-inch screen widescreen: 1680x1050 cTrader, WEP requirements: Operating System Browser Version Windows Mozilla Firefox Latest Windows Google Chrome Latest Windows Microsoft Edge based on Chromium Latest macOS Mozilla Firefox Latest macOS Google Chrome Latest macOS Safari Latest macOS Microsoft Edge based on Chromium Latest Chrome OS Google Chrome Latest Chrome OS Microsoft Edge based on Chromium Latest Linux Ubuntu OS Google Chrome Latest Linux Ubuntu OS Mozilla Firefox Latest 3 Trading Platform requirements cTrader, Android Device requirements: Minimum requirements Minimum Processor Dual Core CPU RAM 2GB Operating System Android 4.4 or later.
    [Show full text]
  • Mt4 User Guide
    UTRADE FX – MT4 USER GUIDE UTRADE FX MT4 USER GUIDE 1 UTRADE FX – MT4 USER GUIDE Installing MT4 on a Windows PC 1. Begin installation by downloading the UTRADE MT4 installer: https://download.mql5.com/cdn/web/uob.kay.hian/mt4/utradefx4setup.exe 2. Run the installer and follow the installation steps on screen. 3. Read the license agreement to continue the installation. 2 UTRADE FX – MT4 USER GUIDE Installing MT4 on Mac operating system Installation of MT4 on Mac systems is a complicated process. MetaQuotes has detailed instructions to install it manually here: https://www.mql5.com/en/articles/1356 System Requirements MT4 is a desktop application available only for Windows. While there are Linux installations, they require a lot of work to install and are not recommended. System requirements for MT4 are low. The platform is designed to use very limited system resources. Minimum requirements: Operation system: Windows 7/10 Processor: 1.5 GHZ RAM: 1 GB Screen resolution: 1024x768 1.5 Mbps broadband internet connection Recommended requirements: Operation system: Windows 7/10 Processor: 2GHZ or higher RAM: 2 GB or more Screen resolution: 1280x1024 or higher 8 Mbps broadband internet connection 3 UTRADE FX – MT4 USER GUIDE Launching MT4 and Initial Login Upon successful installation, the UTRADE MT4 Terminal will appear on your desktop: Double-clicking on the UTRADE MT4 Terminal icon will launch the MT4 trading platform. The default MT4 platform layout is shown below when it is launched for the first time. The platform is only partially functional until logging into either a demo or live server.
    [Show full text]
  • Artificial Intelligence AI Trading Rapid Economic Development Causes Wealth Effect
    Artificial Intelligence AI Trading Rapid economic development causes wealth effect In the past ten years, China's GDP has increased by nearly 300%, which has received strong attention and recognition from the developed countries of the world and is still growing. According to CapitalFM, according to the economic development performance in the first quarter of 2018, Kenya's economic growth is From 2014 to 2015, India's economic growth rate expected to reach 5.4 in 2018. reached 7.3, a significant increase compared to previous years. Some people predict that India will According to the latest report of the Central Bureau soon overtake China. of Statistics of Indonesia, the national average economic growth rate reached 5.07 in 2017, the "Asian Development Outlook 2018" pointed out highest value since 2014. that in the next two years, the Philippines will continue to be one of the fastest growing economies in Southeast Asia. The GDP growth rate is expected to be 6.8, and 2019 will be 6.9, and will continue to grow. Rapid economic development Drive personal wealth soaring 2015 14,5471 20,2456 2016 High Net Worth People High-net-worth people are defined as people with 2017 30,5214 personal assets above 1 million USD. Generally refers to social groups with high investable assets such as personal financial assets and investment properties 51,1546 2018 2019 78,5886 Digital currency daily transaction exceeds 1 trillion US dollars The digital currency market is the most liquid financial trading market in the world today. It is the only market that operates 24 hours a day.
    [Show full text]
  • Top 10 Tips for Choosing a Forex Broker in 2021
    1 COMPARE FOREX BROKERS' TOP 10 TIPS FOR CHOOSING A FOREX BROKER IN 2021 CompareForexBrokers.com TOP 10 TIPS FOR CHOOSING A FOREX BROKER IN 2021 WWW.COMPAREFOREXBROKERS.COM 2 TOP 10 CONSIDERATIONS WHEN CHOOSING A FOREX BROKER Choosing the right forex broker requires careful consideration. There are 10 key features that every trader should research when selecting a new forex broker. Although spreads and pricing drive a traders decision when choosing a broker, there are several factors that contribute to a well-rounded trading experience. TOP 10 TIPS FOR CHOOSING A FOREX BROKER IN 2021 WWW.COMPAREFOREXBROKERS.COM 3 1. TYPE OF BROKERS AND BUSINESS MODELS TOP 10 TIPS FOR CHOOSING A FOREX BROKER IN 2021 WWW.COMPAREFOREXBROKERS.COM 4 There are two basic types of brokers that offer retail investor accounts for forex trading. These are: MARKET MAKER BROKER: also known as a B Book broker or dealing desk broker. NO DEALING DESK (NDD) BROKER: also known as an A Book broker. TOP 10 TIPS FOR CHOOSING A FOREX BROKER IN 2021 WWW.COMPAREFOREXBROKERS.COM 5 DEALING DESK BROKERS Dealing desks or market makers set their own bid/ask spreads (or align with pricing from global liquidity providers) and use their own internal sources of liquidity for the trade. For each trade, the market maker will be the trader’s counterparty, which means they profit when the trader makes a loss and makes a loss when the trader profits. As dealing desk brokers do not charge additional commission fees on top of the spread, spreads are wider than what no dealing desk brokers offer.
    [Show full text]
  • 2018 Ioactive, Inc
    Abstract The advent of electronic trading platforms and networks has made exchanging financial securities easier and faster than ever; but this comes with inherent risks. Investing in money markets is no longer limited to the rich. With as little as $10, anyone can start trading stocks from a mobile phone, desktop application, or website. This paper demonstrates vulnerabilities that affect numerous traders. Among them are unencrypted authentication, communications, passwords, and trading data; remote DoS that leaves applications useless; trading programming languages that allow DLL imports; insecurely implemented chatbots; weak password policies; hardcoded secrets; and poor session management. In addition, many applications lack countermeasures, such as SSL certificate validation and root detection in mobile apps, privacy mode to mask sensitive values, and anti-exploitation and anti- reversing mitigations. The risks associated with the trading programming languages implemented in some applications is also covered, including how malicious expert advisors (trading robots) and other plugins could include backdoors or hostile code that would be hard for non-tech savvy traders to spot. ©2018 IOActive, Inc. [1] Contents Disclaimer ...................................................................................................................................................... 4 Introduction ...................................................................................................................................................
    [Show full text]
  • Technical Support
    TECHNICAL SUPPORT Technical Support Main Section = > New Expert Advisor Installation = > Installation | Diagnosing Technical Issues | Backtester Issues See In this document as well: a) New Expert Advisor, Indicator and MT4 platform Installation b) How To Save and Send a Preset File and Logs from your MT4 c) MT4 Navigational Tips and Techniques” *see videos! d) MT4 Common Errors e) Clues for Win8/Win7 / Vista- Turning of the UAC (User Account Control) f) MetaTrader Strategy Tester: Numbers in the Expert Testing Report as Defined MetaTrader Strategy Tester - Part 1and2 MetaTrader History Data Importing and Converting Tutorial for Quality Backtesting90perc MetaTrader 4 Backtesting & Optimization2 g) Leverage and Margin h) How to Set Up a VPS i) How to Force the MT4 for Automatic Updates j) **Updating database according to broker’s data k) ** EA/Indicator Protection ** l) Remote Assistance – Team Viewer Software m) What does “Old tick” mean? n) MetaEditor Problem o) How to Enable the MT4 email function p) Extra (24) FAQs and Clues !! q) How_to_Send_Push_Notifications_from_your_Metatrader4_to_Android: (Download this file: ) https://dl.dropboxusercontent.com/u/36681905/How_to_Send_Push_Notifications_from_your_Metatra der4_to_Android.pdf r) Installing an MQL4 program-How to compile a MQ4 file (Download this file: ) https://dl.dropboxusercontent.com/u/36681905/Installing%20an%20MQL4%20program- How%20to%20compile%20a%20MQ4%20file.pdf s) MT4 Build 600+ AND some articles of how to use the MT4 Platform t) DLLsIssue u) FTP on MT4 v) Make Your Own Chart Template In Metatrader 4 w) "slippage" and "spread" x) How to know if an indicator “repaints” ©2015 Marcelo Marques Pereira, all rights reserved- [email protected] TECHNICAL SUPPORT a) 1-How to Install the MT4 platform There are two videos below found on youtube that are very straight forward.
    [Show full text]
  • Cgs-Cimb Mt4 User Guide
    CGS-CIMB MT4 USER GUIDE Information in this document is deemed accurate at the time of publishing. However, the information and features elaborated in this user guide is subject to change without prior notice. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of CGS-CIMB Securities (Singapore) Pte. Ltd. The company may have patents or pending patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. The furnishing of this document does not give you the license to these patents, trademarks, copyrights, or other intellectual property. Table of Contents 1. EXECUTIVE SUMMARY ............................................................................................. 3 2. SYSTEM REQUIREMENTS ........................................................................................ 3 3. GETTING STARTED WITH CGS-CIMB MT4 TERMINAL .......................................... 4 3.1 Installation of MT4 Desktop Terminal .................................................................................. 4 3.2 Login of Account .................................................................................................................. 5 4. NAVIGATING THE PLATFORM ................................................................................. 7 4.1 Market Watch Window ........................................................................................................
    [Show full text]