Third Generation Artificial Intelligence Machine Learning Forex Indicator I

In the next series of posts we will practically design and develop a third generation artificial intelligence forex indicator. I hope you have read my previous post in which explained in detail how you are going to code an MACD Signal Line Trailing EA. Now this EA is going to trail price with the MACD Signal Line. When the MACD Signal Line crosses the histogram, it will close the trade. The problem is many times MACD whipsaws. This EA is going to work very well when the trend is very strong and the price is moving strongly in one direction either up or down.  What we want is to make our EA more intelligent so that it know when MACD is going to whipsaw and it stays away meaning it closes the trade before it goes negative.

Did you read the post in which I asked can artificial intelligence neural networks predict forex. If you haven’t read that post that you must read this post before you continue as this post explains in detail what Neural Networks are and how they work. I have posted a number of videos that explain how neural networks work. Basically a neural network is a blackbox that help us model the relationship between the inputs and the output when that relationship is not known. Once we have modeled that relationship we can use it to make predictions. The idea is to develop a model that can give us accurate predictions 70% of the time.

Now Neural Network is one of the algorithms that is being used in Machine Learning. The other algorithms that can help us in improving our predictive powers is the Support Vector Machine, KNN Nearest Neighbor and the Markov Chains. If you are confused you can watch the video below that explains how machine learning can help us in trading!

 

As said above, trading is all about pattern recognition. When we are trading we are looking for certain chart patterns that tell us in which direction market is going to go. When you see a double bottom or double top pattern you know with a high degree of probability that price is going to go down in case of double top and it will go up in case of double bottom. So when we spot a double bottom pattern we have a buy signal and when we see a double top pattern, we have a sell signal. In the same manner, the head and shoulder pattern is a highly accurate pattern that gives signal when the market is going to make a breakout. Divergences are also leading signals that we can use in our chart patterns. So this is what we will do. We will use machine learning to train our forex indicator to recognize the above patterns and give an alert when it thinks that it is the time to buy or sell.

MQL4 is a pretty primitive language when it comes to machine learning. MQL4 is basically a stripped down version of C++. There are not many machine learning libraries in MQL4. Infact there are none. We will have to use other languages that include C++, Python and R in doing machine learning. I will focus more in R and C++ in doing machine learning. What we will do is first connect R with MT4 so that we can easily transfer data from MT4 to R and do the machine learning. Then we will need to import the data back to MT4. You go it. We will need a DLL file to do that. I will cover this more in the next post in which I explain in detail how this has already been done and we can now easily connect R with MT4.

C++ is the best choice for us. C++ is native to MQL4. As said above MQL4 is a stripped down version of C++ and uses its syntax. C++ is a very fast language and time is of essence when we are trading. We need to do the calculations fast. R is also pretty fast but C++ is much more faster than R. We will also need to a built a DLL file that connects C++ with MT4. There are a number of open source C++ libraries that can help us do machine learning. This includes the FANN library for building Fast Artificial Intelligence Neural Networks. We will focus on that. So stay tuned for the next post in which we start our journey to design and develop a Third Generation Artificial Intelligence Forex Indicator that can be used for trading both forex as well as binary options.