How to use Machine Learning (.NET) For Currency Trading Pt.1
Introduction
You should know that some assumptions have been taken. That is:
You have basic knowledge of what Machine Learning(ML) is
You have at least intermediate knowledge of what Forex Trading is
And lastly you know how to program in .NET and you are familiar with the windows operating system or you can run .NET programs in Linux.
Hold on, before you next your way to the next interesting article dispense the “it will be complex” mental frame as ready to run samples will be provided on GitHub. I’ll even throw in pretrained models so you can start from the end and walk backwards. Easy-peasy right? Excellent. Let’s ride.
Tools & Resources
Ok. Grab your favorite energy drink, coffee or a tall glass of water. The set up when you aren’t a .NET developer is loooooong
- Download and install Meta Trader 5 (MT5) from https://www.metatrader5.com/
- Download and install MTAPI to MT5 from https://github.com/mbithy/mtapi
- Download and install MS SQLServer https://www.microsoft.com/en-us/sql-server/sql-server-downloads
- Download and install Management Studio https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15
- Download and install .NET Core 3.1, .NET 4.7 https://dotnet.microsoft.com/en-us/download/dotnet
- Download and Install Visual Studio(VS)
- Lastly fetch The Project (Tembo AI) or Default Release from GitHub https://github.com/Ndovu-Nine/TheProject
Overview Of The Project
As you know good traders do not just simply get in and out of positions at random. In fact all new traders begin by learning the very basics. Then their core (online and free) education is entirely, how to identify potentially profitable opportunities to trade.
After graduating and throwing their hats in the air they rush to the freshest and most recommended broker and soon enough begin paying for real education in losses. Most quit before the final important chapters are ever taught.
This series will not address the later where you learn the final chapters. So if you are thinking I’m gonna f! the market so hard with a free AI I found on GitHub, dispense away that thought.
Back to getting in and out of positions. Okay. There are many ways and many reasons for a trader to decide confidently that for a specified asset during a specified period of time I will buy or I will sell. We’ll focus on that. I’m going to refer this combination of factors as a TRIGGER. As it forces the said trader to take action (BUY or SELL) in the market. For simplicity our samples will use the infamous Moving Average Cross as a trigger for taking action.
After the trigger and because modern machines are so capable compared to when ML algorithms first appeared. We will also monitor and track a plethora of other relevant and irrelevant pieces of information. We will pull those pieces from the broker you chose when you installed Mt5 and opened a demo account. You can also (if you are determined to see the limits of The Project) pull information from other sites that feed retail traders information or even relevant peoples opinions or global market events. Again for simplicity our plethora will be other indicator readings, however irrelevant as they may turn out to be, the aim of The Project is to show you a path you can take and possibly build such a Forex Machine Learning juggernaut you will have to call it Livermore. Giggles…
This pieces of information will now become our FEATURES. In basic English our features here are whatever else was happening in the market, in the chosen asset and even everything else the price action was hinting at. Now, using our trigger combined with our features we will first gather the OUTCOMES. This will be the Collecting Training Data section. Where you will go back as far as possible, only limited by the available asset price history. Outcomes can be in many formats depending on what your goals are for The Project. For example
- Binary/Digital Options — If you will use the project on options then you outcomes will be binary so to speak. It was either profitable or not profitable.
- Classic Forex — If you will use the project for regular retail trading then your outcomes can be the number of points collected during the duration of the open position. You can also granularize further and also collect the maximum points and the minimum points reached during the trade.
Our samples will focus on 1 (options) for simplicity. Therefore automatically our ML.NET algorithms will be Decision Trees, Binary classification. Refresher course anyone? https://docs.microsoft.com/en-us/dotnet/machine-learning/
Once we have collected the features we want at trigger time and saved all that raw data in our database. We will attempt to teach the machine. Then later during forward testing ask it for it’s opinion before we enter a trade. In basic English we will be asking the machine,
IF I take action on this trigger, considering the features provided how likely is it that the position will end in profit?
If the machines opinion is favorable we will open the position. On platforms that allow bot trading you can customize yours to do the trading on your behalf. Mt5 allows for that so classic forex guys will be sipping their drinks while they watch The Project work for them.
Now if that feels like something you want to see or do during a lazy weekend afternoon or otherwise — idk your schedule. Prepare your machine by acquiring the mentioned tools & resources while I prepare part 2. Sound Cool? Excellent.