One Tester to Rule Them All: Introducing The Asirikuy Strategy Tester :o)

Through this and last year I mentioned a few times on this blog how I wanted to developed a strategy tester which could overcome all or most of the limitations of the Metatrader 4/5 strategy tester implementations. The limitations of these platforms are many and – rather sadly – they arise from the fact that Metaquotes caters to brokers (which pay the bills) and therefore things such as strategy testers and providing users with the flexibility to change things is not their utmost priority (with the biggest priority being probably the server side of their software). In order to overcome all the limitations which plague the platform and reach a new level in trading strategy development it is not only necessary but absolutely ideal to develop a new strategy testing platform, a piece of system software which is focused mainly on algorithmic trading and not on any other aspects (such as manual trading or visualization). This platform is the Asirikuy Strategy Tester.

Before venturing further into the development of this new piece of software I first want to go a little bit deeper into the things which I wanted to overcome that have bugged me since I started using the Metatrader platforms. The first and obviously biggest limitation of MT4 (and partly on 5) is the inability to trade on multiple instruments at the same time, you cannot build a system that uses data from X instruments and you have to go by with the development of strategies that take positions on a single currency pair. Although you could – with some creative DLL programming – load and use data from other symbols, it is still true that you simply cannot open/close positions on several symbols in backtesting. So the first thing here is that there is simply an important lack of portfolio development support (big bummer).


The second problem with MT4/5 – partly stemming from the above – is the inability to accurately calculate the contract size in terms of deposit currency when the deposit and term currencies mismatch. For example if you take a USD/JPY long trade on a EUR deposit account the MT4 platforms makes a very bad guess of what the actual value per pip actually is. It is also true that any adjustment the platforms make is based on the last exchange rate from the relevant currency pairs (since the program doesn’t use intra-instrument data) meaning that historically you can have very big problems in this regard. You therefore have another big problem with the evaluation of trading accounts with varied deposit currencies since you do not have accurate contract size determination based on the actual historical exchange rates.

Another problem with the Metaquotes platforms relates to the historical evaluation of swap rates. In Forex whenever you hold a given currency you are paid or have to pay a given amount (called the swap rate) depending on the actual interest rate differential between the currencies you are trading. The Metatrader platforms assume that the current swap rate is constant for the whole backtesting period something which is neither realistic nor ignorable since you could eventually build a strategy which could – without you noticing – rely on the fact that you have an artificially favorable swap rate under a period where this rate was simply not available. An ideal Forex tester would definitely include historical interest rates for each currency which can be used to generate adequate swap rates for all the different currency pairs as a function of time.

There are also many other things which I believe the Metatrader platforms lack which relate to tick-by-tick testing, the inclusion of broker dependency (through random feed distortions) the inclusion of slippage (through similar random distributions of additional costs) the lack of an adjustable spread (or to use real spreads when using tick-by-tick tests, etc). In general the Metatrader platforms are great for some things but they simply lack many of the features that a real serious system developer needs for long term survival. Things such as building and evaluating portfolios, doing walk forward analysis and having an accurate analysis of slippage and broker dependency contributions is something that we simply need to implement if we want to move forward in the evaluation and development of trading strategies.

Now comes the good stuff :o) After spending many days/nights in the development of this project, I am now pleased to announce that I have coded the first version of the Asirikuy Tester. This program will be available soon (this or next week) to Asirikuy members and has many, many features which I have personally wished I had all the time I have been using Metatrader. The program has been coded within Lazarus (using FreePascal) with the idea of making it easy to modify (and contribute to) by Asirikuy members and to ensure that we will be able to easily move towards Linux and MacOS (if someone wants to) going forward. Lazarus – although much less powerful than delphi on several of its components – offers us the blessing of multi-operating system support.

The Asirikuy tester was developed with the idea of object-based modular design in mind so all trading objects are (I believe) very intuitive to use. Strategies for the program are also built using Lazarus (as DLL files) and then they are loaded dynamically into the strategy tester (just as you load systems in MT4). Building a strategy for this program is not very hard and definitely with some well-explained examples I am sure anyone would be able to build a workable strategy from the ground up. Now – before going any further – let me talk a little bit about the features of this new strategy tester:

  • Code and load strategies using Lazarus DLL files (although there is no reason why you wouldn’t be able to use any other language provided that you pass the relevant functions in the right format)
  • Basic charting, chart a symbol’s data and the Open/Close of your strategy’s trades
  • Multi-threading “ready”. I have implemented testing functions to be multi-threading friendly and there is already a very preliminary implementation of this feature (for optimizations).
  • Dynamic loading of strategy parameters (just as in Metatrader)
  • Load symbol information and history directly through a CSV (I also coded a little tool to export this data to a CSV from MT4)
  • Easily change symbol spreads when using OHLC testing (yey!)
  • Strategies can use all symbol/all time frame data at the SAME time (note that I have carefully put together the data so that bar X in all currency pairs matches the exact same time)
  • Can build any upper time frame from base time frame (for example 3 , 20 or X day time frame if you loaded daily)
  • Can open multiple positions on multiple symbols
  • Optimizations (can optimize any parameters including symbols used)
  • Adequate profit/loss determination depending on traded currency pair and deposit currency (the program uses the actual historical rates at the moment of position close to calculate this)
  • Adequate swap rate calculation. The program has saved interest rate data for many pairs and automatically generates swap rate information for each currency pair. The swap profit/loss is then determined using the ACTUAL historical rates.
  • Walk-forward analysis :o) Choose a period to walk forward, a period to analyze and optimization ranges and the program will automatically run optimize-run cycles until the whole testing period is covered. This feature is very powerful as you can even optimize which symbols to use!
  • Random slippage contribution. You can introduce a random slippage contributing factor which affects X% of trades with a max deviation of X pips.
  • Random broker dependency. You can make the program alter X% of your candles by X pips or by X% of the candle’s value. The altered candles are chosen randomly and give you a very good idea of how your strategy reacts against small or harsh distortions in the feed.
  • True tick-by-tick testing (without all the hacking/hassle). The platform has an option which enables you to run tick-by-tick simulations if you have loaded tick data. These simulations use true historical spread levels and run the strategy from each tick to the next.  Right now there is no auto time frame building from the ticks (any OHLC data has to be generated within the strategy using the tick feed given) .
Certainly the Asirikuy strategy tester is still a very young “baby” and therefore there are still many things which have not been implemented. Right now my main focus will be to evolve the program from the point of statistical analysis and optimization with the most important goals being the addition of a powerful statistical analysis module (to give us a lot of statistical analysis information) and the creation of a genetic optimization module which will enable the optimizations to be much faster. Obviously there might also be bugs within the procedures I have coded up until now but certainly the community will help be to quickly find/correct them after the first version is released. A few weeks ago I would’ve thought that this first tester implementation was many months away but gladly I have had the time and desire to work passionately on this project :o)
Another thing which I have been thinking about is that the tester will be quite “handicapped” without an “execution” side to it and therefore I have been thinking about the purchasing of a commercial MT4 server API which was just launched that we could use to interface the tester with MT4 servers and trade the systems developed within it on MT4 without ever having to open a platform. I have already tested a demo of the API and you can certainly get quotes, log into an account, open/close/modify positions, etc all outside the MT4 platform. Additionally this opens up the door to reliable linux execution and to have much lower RAM and processor requirements since all strategies would be able to run quietly with only the minimum amount of calls/resources they truly need. The API is 3K USD so I will test a lot and think about it for a good time before making the leap :o)
Obviously it is important to remember that I am developing this platform for powerful algorithmic trading so my intention was never to develop it with many graphical “bells an whistles” but just to develop something that can work much better than what we currently have for what we want to do. Right now we have a tester that can do a tremendous amount of things which were very difficult or impossible in MT4 and this has made be just tremendously glad :o) If you’re an Asirikuy member, then stay tuned as this wonderful piece of software will soon be released to the community. If you would like to learn more about our community and how you can learn about automated trading 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)
You can skip to the end and leave a response. Pinging is currently not allowed.

15 Responses to “One Tester to Rule Them All: Introducing The Asirikuy Strategy Tester :o)”

  1. F DCG says:

    Hi Daniel,

    This comes at a very convenient time indeed. Compliments on the work so far. I started out 5/6y ago to build something in Java but got seriously side-tracked.
    If you want a sponsor on the 3K API just let me know. I will be more than happy to ‘split the bill’ so to speak .. ;-) .. You got my pm so feel free.
    Cannot make an omelet without breaking an egg or 3 ..

    Splendid effort and looking fwd to have a go at it.

    Cheers
    Fermin

    • admin says:

      Hi Fermin,

      Thank you very much for your post and offer ! :o) Definitely “splitting the bill” sound reasonable and I will be ideally looking for at least 5 Asirikuy members who would like to do this. Members who contribute would get a copy of the API’s source but regular Asirikuy members would be unable to access the source of the part dealing with execution (they would still of course have access to the binaries for this part and source for the rest of the code) per the license restrictions of the API. I will post on the forum this weekend to see if there is any interest, if there is not then I would be glad to split the bill only with you :o) Thanks again for your post,

      Best Regards,

      Daniel

  2. Javier says:

    Hi Daniel, congrats on another great work!!

    I’ve been trying to develop my own “backtesting” tool for quite some time, but never achieved anything serious.
    One of my main concerns with MT4 (other than the ones you listed) is the time it takes to execute each backtest.
    Have you considered performance in your tool??

    Looking forward to test it out!!

    Thanks,
    Javier.

    • admin says:

      Hi Javier,

      Thank you for your post :o) Sure, performance has been one of my main concerns! Each backtest on this FreePascal tester is much faster so I would say that running tests is at least 10x times faster than MT4. Of course depending on what you run exactly (the number of requested higher time frames, etc) it can be slower or faster than that. Also since the program can use multi-threading it can run several backtests at the same time when optimizing so it is potentially much faster than MT4 in the optimization sense. Once I refine the code a little bit more we will be able to go deeper into backtesting speed benchmarks :o) Thanks again for posting!

      Best Regards,

      Daniel

  3. Scott says:

    Wow Daniel, this is huge, and it’s exciting that you’re getting it to us ahead of schedule. Anyone that’s spent any time with the MT4 tester has been frustrated by the errors induced by its assumption that contract size and swap rates over a 10 year period are the same as the current date. The first clue is that you can’t replicate a backtest made at an earlier time, then you realize that neither of the tests is accurate, and the amount of compounded error over a 10 year backtest can be quite large. This is a quantum leap for backtest accuracy, and it will be wonderful to see it continue to develop.

    Thanks so much!

    Scott

    • admin says:

      Hi Scott,

      Thank you for your post :o) I certainly understand your points and this is the reason why I wanted to develop a tester that was a “perfect fit” for our trading strategy evaluation needs as soon as possible. Although there are still a ton of things to implement I do believe that once the community starts to work on it we’ll improve it exponentially as time goes on. This platform already overcomes some fundamental limitations on MT4 and is able to give reproducible backtests (same results every time!). I am glad you view this as a quantum leap :o) Let us hope it is one!

      Best Regards,

      Daniel

  4. Maxim says:

    Hi Daniel,

    My congratulations!
    What is the interface between the strategy under test and the tester?
    How will F4 framework strategies be tested with it?
    In ideal, the tester should be able to run code, written in MQL/JForex in order to make sure that tested and trading codes are the same.
    Please drop me an e-mail if you need software design advice.

    Regards,
    Maxim

    • admin says:

      Hi Maxim,

      Thank you for your post and congratulations! The strategies are coded within a predefined function structure which receives array data, order data, etc. The tester dynamically loads the selected DLL and calls the relevant functions to carry out the simulations. The strategy DLL could also call other DLL files so you can very easily link our current F4 development framework simply by calling the appropriate functions and tying them to the appropriate commands for order entry, etc within a strategy DLL. I definitely thought about compatibility with F4 while coding this ! :o) Once the code comes out I’m sure you’ll be able to help a lot with reviewing as you have done so through the past few years. Thank you very much again for your post Maxim,

      Best Regards,

      Daniel

  5. Franco says:

    Hey Daniel, excellent news! Think I would have kissed you if we were in the same room but that might have lost my membership so very glad you are thousands of kilometers away.

    Jokes aside looking forward to finally scrap MT backtester and migrate to a better solution.

    • admin says:

      Hi Franco,

      Thank you for your post :o) You made me laugh quite a bit there!

      As you say I also hope we can just stop using MT4 soon altogether as an execution and testing platform (guess who has an API now ? ;o) -),

      Best Regards,

      Daniel

  6. emc4x says:

    Hello Daniel,
    Amazing!!!
    Have you heard about Wealth Lab plataform? I have heard good things and maybe can give you some more insights :-)

    Regarding the option to load symbol information, it will be posible to change and create new the contract specification? I have been trying to change/create new symbols on MT4 in order to try the strategies in others financial instruments but I could not do it yet.

    Best reagrds,
    emc4x

    • admin says:

      Hi Emc4x,

      Thank you for your post :o) I am glad you like these new developments! I am also familiar with Wealth Lab but despite the fact that it is an excellent testing platform for some markets (like future and stocks) it misses on some very important characteristics necessary for adequate Forex simulations ( read, broker dependency evaluations, random slippage, swap rates, etc). Definitely I will borrow some ideas from its features going forward :o) Regarding the loading of symbol information, sure, you can specify everything about a symbol (spread, point, contract size, etc) and you can also specify whether it is an FX instrument or not (because non-FX instruments will not be subject to the same calculations regarding swap rates and currency conversions). Definitely this platform won’t put any dumb limits on your testing by design :o) Thanks a lot for posting!

      Best Regards,

      Daniel

      • emc4x says:

        Thanks for your reply Daniel. Sorry for my ignorance in some concepts of programming, but is it posible to run a test of Asirikuy systems using Wealth Lab as plataform? or maybe using the next F4 Framework of Asirikuy this will be posible since Wealth Lab uses C# language?

        Best regards,
        emc4X

        • admin says:

          Hi Emc4x,

          Thank you for posting :o) I would advice against using wealth lab because it was not designed for Forex trading, therefore it doesn’t have real historical swaps and it also doesn’t take into account contract size recalculations for different deposit currencies against different term currencies. However using F4 you could develop a front-end to evaluate it using Wealth lab (it wouldn’t be simply “loading the systems” but you would need to develop all the order handling and array passing structure to match that of the framework). In the end the best thing would be to use the tester we’re developing in Asirikuy which has been adequately designed specifically for FX trading. Thanks again for posting!

          Best Regards,

          Daniel

  7. Jim says:

    Hello Daniel,

    You wrote about several shortcomings within the MT4 Strategy Tester. I think, in order to see the impact of them on the system results / trade statistics, it would be very interesting if you publish a comparison of those results from a given strategy between the MT4 Strategy Tester and the Asirikuy Strategy Tester, if possible on a short time frame with many trades.

    Kind regards,

    Jim

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!
Show Buttons
Hide Buttons