Autonomous Forex Trading Agents Using Machine Learning: The Road to True “Set-and-Forget” Algo Trading?

Every month I usually perform a simple literature search in order to find new and interesting research articles in the field of Forex algorithmic trading. As many of you may know during the past two years I have been very interested in neural networks and what they can achieve in trading but recently – thanks to my friend Fd – I have expanded this research to include machine learning in a much more general sense. This month – while performing my literature search – I found some very interesting examples using machine learning and in particular I have read papers by Rui Pedro and Orlando Belo (links to their papers here), two guys from Portugal who have developed some really nice research in the area of autonomous Forex trading agents. During the following paragraphs I am going to introduce the concept of autonomous trading agents, what some research has found and why this area of research is quite exciting.

Definitely one of the biggest problems we currently have in trading is the design of a trading methodology.  The problem involves everything from deciding how to design a strategy, to optimizing a system once it is fully coded and then deciding for how long it should be traded and when it should be redesigned or re-optimized. The main problem is that this whole process requires the intervention of a human trader in order to design models, test models and choose how models are being used. Ideally we would want an algorithm that could do everything by itself, an algorithm that could have many models to choose from, select models in a way that works historically and then change the way in which it adapts and trades according to its historical results. We are talking here about a trading implementation that is autonomous and can function without any human intervention, evolving in a way that does its best to guarantee profits under unknown market conditions.


Is there such a thing? Is there a way to create a true trading robot? The answer seems to be that there is … at least someone trying :o). Rui Pedro and Orlando Belo have done some extensive research in this area and their approach to the solution of the problem is very interesting. These two guys build their autonomous robots using 3 different pieces that handle different parts of the trading process. The idea is that these parts are able to fully take care of the whole strategy design, decision making and money management aspects of the trading strategy, also evolving trading rules as the market changes and the system needs to adapt.

So how do they do it? The first part of their system is an Ensemble Model that uses several classifiers and regression models in order to draw predictions from the market data. This was very interesting for me because I had never thought about this solution when working with neural networks in the past. Instead of using a single predictive model (for example a neural network) you can use several different types of models that all have different advantages and disadvantages. Within the Ensemble model these guys always include logistic regression models, decision trees, neural networks, etc. In total they have over 10 models within their Ensemble model that are used by the autonomous system to have a variety of “choices” to trade the market. How do we go then from these models to making actual trading decisions?

The case-based reasoning system, which is the second layer of the 3 layered model, handles this part of the puzzle. This part of the model takes a look at what the system has experienced in the past according to previous model results and judges what should be traded and what should not be traded. For example if the system sees that in the past when the random forest and RIPPER rule learner predictors agreed and the system followed there was a profit, then it will bet that there will be a profit again this time if the case repeats itself. The case-based reasoning system analyses all the cases that the system has experienced and their outcomes, with the idea to adapt the system as the number of cases evolves. The quality of the predictors might change over time and the case-based reasoning system handles the relevance of the predictors in a way that can derive the best historical results.

The last part of their puzzle is actually a rule-based section where the system can be told things that it isn’t capable of learning through trading. For example it can be told that the first Friday month is the NFP release or that the trading week should be cut to certain hours (not in hind-sight but to reduce broker dependency for example), etc. This part of the trading model is the least complex as it only includes a bunch of hard-coded rules (that shouldn’t change) which allow the system to improve its results as this information cannot be derived through the trading data.

The most interesting thing about the above is that these guys built a model for the USD/JPY in 2007, using 2003-2007 data (there is no apparent optimization but this was the data they used to test the model) and then traded this same system live from 2007-2008 achieving results that were comparable with those of the in-sample period (they were less profitable but overall acceptable). Through their 2008 paper they also show some of the ways in which the predictors adjusted to new market conditions, which were not available within the period they used for the design of the autonomous implementation. Interestingly enough the results of the financial crisis and the periods that followed were never published in any paper but during the year 2010 they did release a new paper that described a whole multi-system approach that involved several autonomous systems, each trading on its own currency pair.


This  paper was less convincing as it involved different ensembles for the different currency pairs and the inputs of the regression models also involved indicators (which obviously need shift information that is subject to optimization). It is also important to mention that the models were fitted to maximize their individual predictive profits during the in-sample period, showing that the adaptive process was used to yield the best results across a certain set of market conditions. The method used by Rui and Belo therefore has the same disadvantages as a regular NN based system in the sense that the model conditions need to be defined and tested across some given market period. The models can still adapt as market conditions change and the way in which they adapt can in a certain degree be controlled by the case-based model that assigns their lot sizes. They therefore have a fundamentally first degree adaptive technique with some flexibility given by the second model used. The last paper these guys published on the subject – which talks about an Autonomous hedge fund – takes the concept even further, developing autonomous systems that trade FX, futures, stocks, etc.

One of the things that Rui and Belo achieved – which I haven’t been able to – is to produce adaptive models that give significantly profitable historical results in currencies besides the EUR/USD. Implementing some of their ideas and improving on several of them will also be part of my check-list for 2013. In order to do this I plan to use the C++ shark open source machine learning library and some imagination :o). If you would like to learn more about the NN systems we have developed and how you too can use F4 to implement your own neural network ideas  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.

4 Responses to “Autonomous Forex Trading Agents Using Machine Learning: The Road to True “Set-and-Forget” Algo Trading?”

  1. Jacob says:

    Interesting article, Daniel – might be a very nice addition to the NN implementations already developed:-)
    Looking forward to hearing more about this;-)

  2. davidautentico says:


    Take a look here:

    Encog is a powerful machine learning framework written in java. It is completely free and open.

    • admin says:

      Hi David,

      Thank you for your post :o) I am aware of this library (Encog) however I never used it because FANN was able to provide us with all the NN needs we had. With machine learning Shark now seems more powerful and directly coded in C++ while Encog is mainly coded in java an the C libraries can routinely run out of date. Of course, this doesn’t mean that Encog is a bad library (it’s excellent as far as I’ve heard) but shark seems better accommodated to our needs. Thanks again for posting!

      Best Regards,


      PS: I have already implemented shark in F4, you can see some first results using LDA algorithms in the Asirikuy forum

  3. Justin says:


    I understand this an old post, but I just found it. Have you had any success building this system? It is a complex system to code.


Leave a Reply

internal_server_error <![CDATA[WordPress &rsaquo; Error]]> 500