No more MT4 Back-testing! :o) Moving to a professional, C/Python Backtester for the F4 Framework

During the past few months it has become evident – as I expressed in my open letter to Metaquotes – that the Metatrader platform has become a hostile environment for system development and professional live trading. For this reason it has become a priority for me to develop alternative solutions to all the needs that up until now had been fulfilled by this platform. Amongst these needs, one of the most important is clearly the historical evaluation of a strategy’s performance, also known as back-testing, which is fundamental to the development of algorithmic trading systems. During the past two months I have been working tirelessly with an Asirikuy member from Spain (Jorge) to develop a professional and robust solution that would allow us to back-test trading systems outside of the MT4 platform, without all the ridiculous and stubborn limitations imposed by Metaquotes on their strategy tester. Our efforts have created a C/Python tester assembly that is able to perform accurate and powerful historical tests, way beyond the many limitations of the MT4/5 trading platforms. Through this post I want to share with you some of the achievements we’ve made as well as some of the functionality we are planning to implement going forward.

The Metatrader 4 strategy tester has never been an ideal back-testing solution, when working with this tester you always feel like you’re working “around it” and not “with it”. The MT4 back-tester suffers from some severe limitations in functionality that have been generated by the stubborn Metaquotes attitude towards the implementation of trader suggestions. For example you cannot select the spread used for back-testing, when the implementation of such a feature is as obvious and as simple as adding a few code modifications. Besides this there are other problems with configuration, a very limited set of statistics for optimization and a general lack of knowledge about how the different statistical measurements are calculated by the tester. You also have a completely  ”hard coded” genetic optimization algorithm that you cannot modify or tweak to match the needs of your particular optimization procedure. There are other factors that inherently affect simulation accuracy, such as the use of constant swap rates through the whole historical period (as I mentioned on a recent post as well). Metatrader 5 fixes some of these things but introduces yet worse problems, such as the inability to load custom historical rates (so you have to carry out simulations with whichever data your broker’s server wants to give you). On top of all of this the MT4 platform has no multi-core capabilities, taking no advantage of modern processor process distribution capabilities.

-

Screen Shot 2013-06-07 at 4.53.23 PM

-

We – at Asirikuy – decided to develop a tester with Jorge that would fix all of these limitations, providing us with a very powerful testing framework that could allow us to get rid – for once and for all – of the MT4 platform’s strategy tester. Using the power of the F4 framework it was rather easy for us to develop a tester because we can use the exact same code used for live trading in Mt4, but carry out the back-testing under a completely different environment. There is no uncertainty about the code in simulations and live trading being any different, because the strategy implementations are simply exactly the same (the same code is executed for live trading as it is for back-testing). With all of this in mind we developed a tester that now far exceeds the capabilities of the MT4 back-tester for our back-testing needs. These are the current capabilities of our C/Python backtester solution:

  • Cross-platform compliant. The tester has been coded/developed so that it can be compiled under Linux/MacOS (although we still haven’t run tests under these setups).
  • Multi-core support using OpenMP
  • Supports MPICH, meaning that you can run the tester across even large computer clusters. This is a feature that I haven’t seen in any other back-testing software. Want to run an optimization across 10 computers with quad processors using a total of 40 cores? No problem!
  • Optimizations using either brute-forcing or genetics
  • Genetics are implemented using the powerful open source GAUL library. You can fully tweak ALL the parameters of the genetic optimization (mutations, breeding, migration probabilities, initial population, number of generations, etc).
  • Optimizations can automatically eliminate results with few trades, asymmetric results, etc. This is a huge improvement over MT4 as genetic optimizations do not converge to bad solutions as easily.
  • Wider available statistics for optimization (correlation coefficients, Ulcer index, profit factor, etc)
  • Custom statistics can be implemented. As the source of the tester is fully available, you can simply implement any statistics you want to use that are not added by default.
  • Test systems across multiple symbols. This means that you can carry out an optimization that simultaneously evaluates a system on N currency pairs.
  • Portfolio simulations. Do you want to evaluate how the A+B+C combination of systems would have worked historically? No problem!
  • Accurate historical swaps! Derived from historical interest rates obtained from Oanda.
  • Ability to select any spread level desired :o)
  • Images generated for balance curves, historical swaps and volumes.
  • HTML/XML and CSV format reports are generated after each test. The HTML reports even allow you to sort trading results by using the column headers!
  • Console and visual interface access for easy configuration and running.
  • Configuration files are easy to share, meaning that you can allow other people to easily reproduce your tests by simply sharing a file. No more irreproducibility!

As you can see our tester implements capabilities that far exceed those of the MT4 platform, giving us the opportunity to completely get rid of the MT4 strategy tester (as we have confirmed as well that our simulation results are accurate as well). With our new back-tester we can now perform tests in the manner that WE choose to be the best, optimize the variables WE want to optimize in the way WE want to do it and evaluate the setups WE want to trade. We can now run our portfolios and see how they have done historically (in a direct manner) and we can also carry out optimizations that target strategies that match our stability criteria. We can also simultaneously optimize a strategy across several instruments or even different feeds of the same instrument, to find parameters that generate the most robustness or the least broker dependency.

Our implementation is however quite new (only about 2 months from our first code writing) and we still want to implement other things to further the capabilities of our testing platform. For example next week I am going to be working on the implementation of multi-symbol capabilities, giving us the ability to test a system that uses information from several different symbols to make trading decisions. This will give us the possibility to develop systems that exploit inefficiencies that work through the whole currency market, not focusing on information from a single symbol to make trading decisions (things such as correlation based systems could be properly evaluated with this implementation).

-

Screen Shot 2013-06-14 at 6.13.39 PM

-

As you can imagine, the above gives us a potentially huge advantage against traders who only have access to the MT4 platform, simply because we have the capabilities to work above the limitations of this tester. We can run tests in a faster way (take advantage of multi-core or computer cluster setups) and we can also carry out simulations that the people using MT4 simply cannot do (for example optimizing a system simultaneously for various pairs). In addition the added accuracy of our simulations – thanks to our accurate historical spreads – gives us an additional edge as we cannot be “fooled” by problems that stem from the assumption of constant historical swap rates (as discussed in my last post). We can also run directed optimizations – as we can control the variables of the genetics and target values – meaning that we can arrive to better solutions within the parameter space in a faster manner.

Last week I carried out what I hope will be my last back-test ever in the MT4 platform. Right now I am using our C/Python tester and I am extremely happy with it’s speed, results and capabilities. From now on I will only run my tests on this implementation and hopefully by the end of this year – as I mentioned in my open letter to Metaquotes – I will be able to get rid of MT4 for live trading as well. I will also start to move our community members away from MT4 back-testing in the hope that they will embrace our new and powerful C/Python back-testing solution :o)

If you would like to learn more about back-testing outside of the limitation of the MT4 platform please consider joining Asirikuy.com, 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

You can 8 Comments, or trackback from your own site.
Subscribe to RSS Feed Follow me on Twitter!