Skip navigation.
https://www.metatrader5.com/
Metatrader community - Forex Trading with Metatrader

MetaTrader Strategy Tester – Part 2

We have explored the MetaTrader Strategy Tester (MST) window in the previous article (Figure 1). We know now every option in that window and we have reached the Start button. You are a click away testing your strategy but I have to tell something about the accuracy before starting our testing.

Accuracy:

As I told you before in the previous article that there’s nothing is 100% accurate but there’s a possibility of better accuracy if we set all the required conditions.
Today we will know how to get the maximum of MST accuracy by the setting some of its conditions.
These are the required steps you must take to get the maximum of MST:

MetaTrader Settings:

The first step you have to take to get the accurate result you desire is changing the Max number of bars in the history in MetaTrader seyyings.

Go to MetaTrader Tools menu and choose Options (or click CTRL+O hotkeys). In the Options windows choose Charts tab and in the field of Max bars in history inter a very large number like "9999999999999" Figure 2. MetaTrader will reset this huge number to the maximum value the program can accept. This might eat some of your hard disk space but it's very important condition for accurate testing.

Figure 2 - Max bars in history.Complete history data:

 Complete history data:

The data you getting from the broker server while you are running your demo account is filled with gaps and missing a lot of real data. You can't relay on this data in your strategy testing. So you have to download a complete history data and import it to MetaTrader to have the opportunity to get more accurate results.

You need to have a complete data for all the timeframes available in MetaTrader (1 minute, 5 minutes, 15 minutes, 30 minutes, etc). But if you can get a complete 1 minute data it will be easy to use the Period_Converter script shipped with MetaTrader (we will explain how to use it) to convert the 1 minute data to all the other timeframes data.

The free and complete (from 16/06/2004 up-to-date) 1 minute data can be downloaded from Alpari Databank by following this link:

Note: For every currency pair there is a file available on the Alpari website. Choose the currency or currencies you want to work with and download their data. And don't forget to choose the MetaTrader 4 format (there are another platforms formats). The size of the file is a quite big so be patient and choose the data you want to work with now. In our article we are going to work with EURUSD data and I assume you are interested in the same currency.

Download the MetaTrader 4 Format 1 minute data and extract the file to clean folder. The extracted file will have this name "M1_EURUSD.hst" which means "1 minute EURUSD history data".

You have to import the 1 minute data to MetaTrader database by going to Tools menu and choose History Center (or click F2 hotkey). Then choose the EURUSD 1 minute period in the left menu (Figure 3).
Click Import button and a window like Figure 4 will be pop up asking you to browse for the ".hst" file contains the data. Click Browse button and the open file dialog window will pop up again (a lot of pops be patient) like Figure 5. Choose from the drop down list of Files of type the option of "MetaQuotes files (*.hst) then browser for the "M1_EURUSD.hst" file you have extracted and click Open.
That will return you to the Import window again filled with the contents of .hst file. Click Ok button to return to the History Center window.

Figure 3 - History Center

Figure 4 - Import

Figure 5 - Browse

Note: If you noticed the number on the top of History figure 3 was "32375", it's the number of records in the database, you have to examine that number after the steps you have token above and it must be greater than the previous number. My new record number after importing the 1 minute data is "490312".

Close the History Center and you will be a lucky person with a complete 1 minute history data right now.
It's the time to convert the 1 minute data to the other timeframes, but why are we doing that, isn't the 1 minute data enough?

One of the most important conditions to get accurate results of the MST is using EVERY TICK MODEL which uses for the price generation not only the data of nearest smaller timeframe (like Control Points Model) but also all of the smaller timeframes available. And this is the only way we can fill the gaps and the holes in the history data we test our strategy with.

Converting 1 minute data to the other timeframes:

1- You have to open the 1 minute data on offline chart by going to MetaTrader File menu and choose Open Offline and choose EURUSD,M1 (Figure 6) then click Open. This will open the 1 minute data in new chart.

Figure 6 - Open offline chart

2- Double click the Period_Converter script and that will pop up the Inputs window, change the value of ExtPeriodMultiplier from 3 to 5 minutes (Figure 7).

Figure 7 - Period

This is the period of timeframe you want to convert the 1 minute data to. Click OK to close the Input window and start the conversion. You will notice that in the Expert tab the progress of the conversion (Figure 8).

Figure 8 - Conversion in progress

3- You have to repeat step 2 with changing the ExtPeriodMultiplier for every timeframe. So you will change it to 15, 30, 60,240, and 1440.

Note: Maybe you get a message like Figure 9, ignore this message and click "Yes" and notice the Expert tab to see the progress of the conversion of each period.

Figure 9 - Ignore this message


In the coming part of this article we will start our testing and you will the maximum of MST after the long path of settings we have walked.

Coders' Guru