How to backtest with accurate history data in MT4

8 February 2022, 16:38
Jesper Christensen
1
8 116

In order to vet a potential trading strategy, it is imperative to ensure that the results obtained from optimizations and strategy tests are a true reflection of the performance of your EA. Unfortunately, the history data provided within metatrader is not high quality and also you will not get more than a few years worth of history data to test your expert advisor on. 

If you want to get a 99.9% history quality of your backtest and optimisation, this is the guide for you!


The problem with using broker requested data in MT4


On MT4, back-testing on “ Every tick” with a default environment is the highest accuracy possible. 

The utilisation of “ Every tick” modelling causes a variety of issues. Prices that are randomly simulated from bar data when the default tick data is downloaded from the broker through MetaTrader’s Strategy Tester. By a process of interpolation, it uses the bar price data together with the tick count to generate the prices for each bar so that they start at the bar open price, touch the bar high and low, ending at the close price.

To summarise, the default testing environment   will not cycle through every tick that was delivered at the specific points in history. This will be a lesser issue for higher timeframe EAs, but for scalping EAs, as in the image above, the results will divergence extensively.


The solution


The two third-party tick providers (intermediaries) allow for a user-friendly method for accurate testing with relatively low costs. The steps below will outline how to utilize Tick Data Suite (TDS) for the entire process. A similar process can be followed for Tick Story.

TDS is a paid service, but does allow for a 14-Day free trial, available here.


Downloading Tick Data


Once TDS has been downloaded, run “  Tick Data Manager” from the Windows start menu.

  • Choose the source (broker)
  • Dukascopy has almost every forex, commodity, stock/equity, bonds and more available as CFDs
  • Alpari ECN1 and Alpari ProECN are both ideal for users who are planning on live trading on ECN accounts (orderbook), but does not offer as much history data as Dukascopy. Therefore, if you want to backtest your EA on history data older than 2015, you probably want to go for Dukascopy. 

  • Then click the download button (arrow-down symbol) on the far right of each desired pair’s row. 
  • Insert your desired time period
  • Click on "Start download"



Using the Tick Data for backtesting in MT4


Once you have downloaded the tick data you need, it's time to open your Meta Trader 4 Application. (If your MT4 terminal was open while you downloaded the tick data you need to close your terminal and launch it again)

When you start your MT4 terminal after having Tick Data Suite installed you will now see a few more options in the strategy tester. 

  1. To use the tick data, check the chekbox named "Use Tick Data"
  2. Select the testing model to "Every tick.
  3. In the "spread" dropdown, choose variable spread (With variable spread selected, the strategy tester will use the actual spread that your broker provided at the time of each order execution in your backtest)



Emulate real trading conditions and include trading fees: 

Click on "Tick data settings.


On the "Basic" tab: 

  1. Select the GMT offset and daylight savings time (DST) your broker uses. 
  2. Check the boxes "Use variable spread" and "Enable slippage"

On the "Advanced" tab: 

  1. Check the "Commission" box. 
  2. Insert the commission charged by your broker
  3. Check all the boxes under "simulate live execution" to true



When backtesting, just make sure to use the test model "Every tick" and select variable spread, then you will get a 99.9% accurate backtest. 


Safe trading!!



Share it with friends: