Neural Networks in Trading: Developing Sunku, Our First Likely Long Term Profitable Asirikuy NN Adaptive System

During the past few months I have started a series of posts called “Neural Networks in Trading” in which I have talked about the different aspects of practical neural network development for automated trading strategies. After describing some of the generalities of neural networks and the proper evaluation of systems developed with them, it is now time to start talking about practical examples and their applications in algorithmic Forex trading. On today’s post I will share with you some of my advances in this regard which have been collected within an EA I have decided to call Sunku – meaning door in Quechua – as it is the “door” to a whole new world of development dealing with NN based systems.

The road in the development of likely long term profitable systems using neural networks is not an easy or short one. It has been evident during the past few months of development that neural networks are not very accurate predictors of actual future market values (with the best predictions of daily closes having an average standard deviation of +/- 50 pips) and even when prediction are accurate it becomes difficult to derive strategies from them since you must not only take into account how frequently you’re wrong or right but “how right” and “how wrong” you are in average.

The building of a system that yields a ten year profitable back-test using Neural Networks is not at all trivial. There are several problems which need to be overcome which start mainly with the fact that neural networks simply yield some predictors which must be molded into some type of system with a positive mathematical expectancy. Carrying out several ME analysis of the predictors within a neural network it becomes evident that they carry a certain edge which can be exploited successfully if adequate exit and money management strategies are used. Nonetheless – and I will leave this for a full future post – it becomes evident that certain currency pairs are more inefficient towards neural networks (more easily modeled) than others.

Another important milestone in the creation of an MT4 NN strategy was the implementation of an NN dll which allowed me to perform network training and running while running backtests. This has allowed me to properly evaluate my NN strategies since I can simply make the EA retrain the network and rerun it every X number of bars, right during the backtest. My first successful attempts have used information derived from the past 100 bars, retraining every 5 bars. This means that Sunku is able to automatically adapt to changes in market conditions as it “rewires” itself every new week. This is – as a matter of fact – the first EA we will have which will have an absolutely automatic self-adaptive mechanism to “learn” from the market, the first machine learning experiment within Asirikuy.

The next significant hurdle in the way appeared when I considered the reproducibility of the back-tests carried out with Sunku. As the EA trains its neural network based on random weights, every new backtest -although profitable – was very different from the backtests executed just before it. This is because every training process gives new results which are similar – but different – from the results generated before. In this regard it became clear that any live test was going to be different and problems due to this matter would arise, having random worst case scenarios is -after all – something we do NOT want.

In order to solve this problem I resorted to the idea of neural network committees. Sunku now uses 5 different neural networks and only executes trades if they all agree in what is going to happen. The EA therefore has 5 instead of 1 “brain” which are retrained every week in a separate fashion. Since results that are “good” tend to converge between networks not only was the EA able to have much more reproducible back-tests but the profitability within the tests was increased by nearly 50%. In the end Sunku became a very cool strategy with self-adaptive capabilities and 11 year profitable backtests. Surprisingly — although this will also cover another post – on the pairs where it works Sunky can succeed on 4H and 1H time frames, showing that predictability of certain pairs also falls onto these lower time frames.

Now it is important to understand that Sunku is NO holy grail. The EA achieves modest average compounded yearly profit to maximum draw down ratios at the moment and has long and deep draw down periods just as ANY other likely long term profitable trading system. However Sunku has the advantage of being inherently more robust since it is able to have a level of plasticity other systems are simply not able to achieve due to the fact that its entry logic (the mechanism used to make a decision to Buy/Sell) adapts every week towards what has happened within the past 100 days. Sometimes this is very successful and sometimes it is not but the EA is continuously “learning” and evolving to capture what the market has to offer.

Certainly a few months will pass before this EA is released into Asirikuy as I have yet to test many new ideas and to refine current ones. However this is in fact a demonstration that likely long term profitable self-adaptive systems are possible and that such an implementation can be made on the MT4 platform. In the not so distant future Asirikuy members will have a very powerful system with the ability to adapt to what happens on the market with the capability to morph every week as new challenges appear. Through the next few days, weeks and months I will share with you more about my experience with Sunku and what it has been able to achieve.

If you would like to learn more about automated trading and how you too can learn to develop trading strategies with robust and sound trading principles please consider joining, a website filled with educational videos, trading systems, development and a sound, honest and transparent approach towards automated trading in general . I hope you enjoyed this article ! :o)

Print Friendly, PDF & Email
You can leave a response, or trackback from your own site.

9 Responses to “Neural Networks in Trading: Developing Sunku, Our First Likely Long Term Profitable Asirikuy NN Adaptive System”

  1. Vitor Ramirez says:

    It seems you are creating a Frankstain. Be scared pips,be very scared !! :o)

  2. Alex says:

    I have just read a book called Quantitative Trading by EP Chan. He extensively uses Matlab (which has a vector based programming language) and Alphacet Discovery, amongst other tools. He also shows some machine learning code using Alphacet, to perform optimization,…

    He is explaining that Matlab and these other tools have a bunch of modules and frameworks like for example genetic algorithms, different neural networks, …

    A direct price feed to one of these tools, and then using an API or even more simply a DLL/event/socket to Metatrader could be an alternative to your in house NN + MT4 DLL ?

    Note that i know nothing about Alphacet, and this is not some kind of advertisement of anything. Just asking if you already used proprietary or canned trading software before redoing your own framework and devising solutions around MT4 which you already showed all its imperfections and slowness. I personally do have this problem to try to rewrite everything myself and that kills my productivity. Yet i can’t help it !

    • admin says:

      Hi Alex,

      Thank you for your comment :o) I answered your inquiry regarding Matlab on the FreePascal post you commented on a few minutes ago. Regarding the NN implementation, the DLL is based on Delphi code which is based on FANN an open source neural network implementation. After testing a few networks FANN came out to be a very professional and well made implementation which has the advantage of being completely free. Bear in mind that I implement everything with the Asirikuy community in mind and therefore a solution like matlab – with a cost above 1K USD per license – is not something I would like to implement. In my mind you can come up with far more robust stuff (and the understanding that accompanies it) if you develop things yourself (how I approach things in Asirikuy). In the future if we move beyond Asirikuy the NN DLL I have developed will work with whatever implementation you want as it is totally independent from MQL4. I hope this answers your inquiry :o)

      Best Regards,


      • Alex says:

        I had no idea it was so expensive, I though it was cheap when we used it in Uni (well, around 12 years ago), or maybe it was a free clone. Or maybe I mismatch with MathCad

  3. Franco says:

    Alex, Universities get Matlab student licenses for free, for educational purposes only. I’m using one right now because I’m a student :)

    Daniel increadible job with your NN adaptation, I’m shocked to be honest, I always thought NN are one big bluff in trading and that it will never work. Guess I was wrong :)

    About Matlab, the learning curve is huge, but if you know Matlab from A – Z then NOTHING can stop you. Matlab is the most powerful mathematics software package on the planet, you can do just about anything with it. For $1000 it is a bargain.

  4. Alex says:

    Nothing to do with the subject, but is it only me or is it not possible to receive emails notifications where comments are posted on a post to which we commented ?

    • admin says:

      Hello Alex,

      Thank you for your comment :o) Sadly there are no email notifications for comments,

      Best Regards,


  5. npat says:

    Hi Daniel

    I have some specific questions and assistance. Hence, kindly provide an email contact for your self.

    Thanks and best regards


Leave a Reply

WordPress › Error

The site is experiencing technical difficulties.