MOOSE * Monitoring Online Of Securities Exchange

[ Log In ]

MT4 Back-Testing

The MetaTrader4 Strategy Tester allows you to load up your EA or bot and assess it's performance using historical tick data for the symbol and timeframe of choice. The results can be viewed and saved to an html file. Whilst this is undoubtedly useful, there are some notable caveats relating to backtesting of bots, however.
Firstly, bot backtest results can be inconsistent even using the same bot, symbol, timeframe and test period. This is due to the way MT4 determines the spread to use for each transaction. Secondly, whilst the MT4 strategy tester results are of value, there is no easy way to perform quantitative data analysis comparing the bot performance using different configuration scenarios.
The following video tutorial discusses these issues and shows how to resolve them. 


Spread Changer

The excellent Spread Changer tool by Fai is available for download - or find it on google. The tool allows you to set the spread for any symbol to a sensible value which the tester will use during back tests. This allows consistent results even at weekends when symbol spreads may be set unusually wide because the markets are closed. The file to edit is called symbols.sel and is located in the /history/[account]/ sub-folder of your MT4 platform. Remember to exit your MT4 platform before editing the file, and when you restart the platform, keep it offline as explained in the video.

Analysis of Results

With consistent spreads in use, it is possible to produce more reliable results from the back-tests. To properly determine the profitability of a bot requires back-tests using as many scenarios as possible ie. different time frames, different time periods, different symbols and different configuration parameters such as stop and profit targets.
You can add the following MT4 include file, BotReport.mqh, to your MT4 platform. You will need to #include it at the top of your source code, and call the BotReport() function from the deinit() function of your EA. The code will calculate a frequency distribution table based on the number of pips made or lost for each test cycle.

BotReport.mqh (source)
BotReport.ex4 (compiled)

The results are saved to a .csv file in the /tester/files/BotReport/ sub-folder of your MT4 platform. You can open this .csv file using Microsoft Excel to analyse the results. The video explains how to use an Excel Pivot Chart to view the performance profile of your bot.

MOOSE