MT4 Backtest Data At 90% Quality

First we will focus on how to get 90% modeling quality, in order to that you will need to run an offline installation of MetaTrader 4 for testing purpose only. This way you will be able to reliably reproduce the same condition when changing settings on the expert advisor or comparing different expert advisors.

Step 1 – Custom MetaTrader Installation

To get an offline MetaTrader working you will need to choose a different folder during the installation process, in this case we will use: C:\Program Files (x86)\MT4 Test

After the installation completes open a demo account and update the Terminal if outdated. When this is done you will need to install your expert advisor on the expert folder, you will also need our free Spread Indicator and the free Auto_Converter Script.
The reason is that MetaTrader does not vary the spread during optimization but your broker may, so if you do a back testing and the spread varies a few pips you will get very inaccurate results.

Step 2 – Getting the correct spread

Place the 4xSpread indicator on the symbol that you like to use for back testing then wait until the spread is at your desired level, then you take MetaTrader offline, that will freeze the spread at this level until you connect your Terminal to the internet again.

You can make MetaTrader go offline by deleting the account from the Navigator window (control+N), right click on the account number and choose Delete. If for some reason you did not get the correct Spread amount you can open a new account from: File –> Open Account Menu and repeat this steps.

Step 3 – Deleting old History Data.

Close MetaTrader, go to the folder where MT4 has downloaded the history data and delete all the files with the .hst extension.
In this case the files are in this folder: C:\Program Files (x86)\MT4 Test\history\FXCM-Demo\

Step 4 – Download History Data.

Now you´re ready to import historical data for the pairs you want to test, you can use the data from: http://www.forextester.com/data/datasources.html ; they have about 9 years of (1 minute) historical data for the most common pairs.

For this example I will use the EUR/USD, click on the link of the pair of your choice and download the zip file, when done open the zip file and place the text file on your desktop.

Step 5 – Importing data into MetaTrader

Open your offline MetaTrader and you will get 2 screens asking you to open a new account. It is very import you press cancel on both.

Press Control+O to bring up the Options Screen, navigate to the Charts tab and change the MaxBars in History and the MaxBars in Chart to 99999999 as seen on the image below, then hit ok.

Now press F2 and the History Center will pop up, navigate to the EURUSD 1 Minute button and double click on it, there should be no data on that screen just like the screen shot below, if you see any information here you need to go back and repeat step 3.

Click on the Import button and then click on the Browse button to navigate to the desktop where you saved the history text file, set “Skip:” column to 1 then press OK (see image below), close all screens and close Metatrader.

It takes time for the history file to be saved, it is very important that you wait about a minute before reopening MetaTrader, otherwise data may not import correctly.

Step 6 – Converting the 1 minute Data

Before you can test you Expert Advisor in MT4, you will need to run the free script form “Step 1″ to convert the 1 minute data into 5 minutes, 15 minutes, 30 minutes, etc.

Open the EURUSD chart and change the period to 1 minute then run the Auto_Converter script on the chart until you get a “done…” message.

Close MetaTrader for the last time wait a minute and reopen it.

Now your MetaTrader Station will give you 90% Modeling Quality on all periods with the exception of 1M, where the maximum quality possible is 25% ( for more info on why 1M quality cannot exceed 25 % see this article: http://articles.mql4.com/93 )

Note: We recommend to have one installation for each pair with the correct spread amount, because it is unlikely that you will be able to have the correct spread for several pairs on the same MT4.
You should never run a back testing for a date later than the date provided by the downloaded data.

If you’d like to achieve 100% modeling quality check out this other article: http://www.eareview.net/tick-data

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s