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) .