Thursday, October 15, 2009

Neural Networks in Metatrader 4 using FANN

Through the past few years I have noticed that more and more people have become interested in the use of neural networks in the development of forex automated trading systems. Most people seem to believe, even if they don't fully understand them, that neural networks are the ultimate tool to profit from the market. My objective with this post is to describe the latest development in the implementation of neural networks in metatrader 4 as well as to give a description about what neural networks are and their inherent limitations.

Most people believe that neural networks give the computer a "brain" or a constantly updated "artificial intelligence" that will give any program a human like capability to trade and adapt to different market conditions. There is nothing further away from the truth. Although a neural network does try to simulate to a certain extent the way in which biological neural networks communicate, it does not work the same way. Neural networks are formed by a series of computer processes (neurons) that work in tandem to achieve a certain result. Usually, the "importance" or weight of each neuron's process is changed via an optimization with a fitting set and then the neural network is set free in the true working environment.

In trading this can mean several things. For example, a neural network can be used to say if we should enter a trade long or short with a 50 pip stop loss and take profit based on price movements. A fitting set of X years is fed to the neural network which analyses all possible trades on different price movement conditions and determines which ones are the ones that generate profit. After this, we trade the neural network on the real market and it filters trades according to what it "learned". Note, that the learning and execution processes are totally separate so no true dynamic adaptation ever happens.

Neural networks, as a matter of fact, have not been very successful at forecasting prices since they tend to over optimize themselves to a given set of market conditions, therefore failing afterwards. However it has been found that neural networks are very good at filtering signals from classic trading systems so you could feed a neural network all the positions a strategy took for the past X years and the network could then filter unprofitable results in the future with some success. It is not artificial intelligence but rather a way of doing "intelligent optimization" of a trading system.

All these implementations had been quiet difficult to make in metatrader 4, previously needing a lot of external coding in the form of dlls. Quiet frequently, most of these efforts were limited to a few individuals with no access to other programmers who did not have a ready to go way to program and play with a neural network using the mt4 trading platform. Gladly, I found an article about the implementation of FANN (Fast Artificial Neural Network Library) on mt4. The article talks about the implementation of all the FANN functions and the porting of the functions into the mql4 environment. There is also an example included in which a MACD strategy is optimized using a neural network approach.

Without a doubt, this opens up a huge door for the use of an opensource neural network program in automated trading. I will for sure play a little bit with it and certainly try it for the optimization of certain trading strategies (Maybe we could reduce the draw down periods of some long term profitable strategies by using this type of approach ?). I do hope you read the above article which explains all the aspects of the FANN implementation as well as some ideas on how FANN can be used in automated trading.

If you would like to learn more about the long term profitable trading systems I use as well as how you too can design and program your own long term profitable trading systems please consider buying my ebook on automated trading or subscribing to my weekly newsletter to receive updates and check the live and demo accounts I am running with several expert advisors. I hope you enjoyed the article !

1 comment:

Hansen said...

Hi Daniel!
Interesting article - hadn't spotted it before today.
Have you ever looked at the Snowcron articles about use of neural networks in metatrader?
If you haven't, here are some interesting articles about just that:
http://cortex.snowcron.com/

Kind regards
Jacob

Daniel Fernandez's Expert Author Email Alerts
Sign up to receive email alerts of Daniel Fernandez’s latest articles from EzineArticles.com!

Email Address: