How to Achieve 90% Modeling Quality When Testing Expert Advisors on MetaTrader 4 Strategy Tester
Rule #1: You MUST use a separate installation of MT4 for testing Expert Advisors. This is not an option. This special installation of MetaTrader 4 is the one that you will use from now on to test your Expert Advisors.
Summary of procedure
• Install separate instance of MetaTrader 4 for Expert Advisor testing only
• Update your installation of MetaTrader 4
• Delete demo account and .hst files
• Download Alpari data
• Import Alpari data into MT4
• Convert M1 data to the different time frames
• Restart MetaTrader 4
Install separate instance of MetaTrader 4
Install MetaTrader in a separate folder. If you already have MetaTrader 4 installed for trading then you will want to download the MetaTrader installer and run it again. During the installation, the wizard will ask you what directory to install on. Make sure you specify a new directory here when you get to this part. Then just run through all the default values of the installer. At the end of that process you will have installed a new instance of MetaTrader 4 on your computer. This one you are going to use for testing only.
Update your installation of MetaTrader 4
After the installation open a demo-account so MT4 can update itself. (Note: You will do this only once!)
Delete demo account and .hst files
After MT4 has updated itself, delete you account by selecting it from the left menu and selecting “Delete” you will be asked for confirmation. Say OK to delete the account. If you do not do this your history data will be overwritten every time you open a chart. Make sure you never have an active account on the instance of MetaTrader that you use for testing.
Navigate within Windows Explorer and find the folder where you have installed your test
version of MT4. Open the folder called “History” and delete everything that ends with *.hst.
Download Alpari data
Now you’re ready to import the historical data for the pairs that you want to test. But first you must download the data. Here is where you will find it.
Go to the Alpari site listed above and download the one minute (M1) data for the currency pairs that you want to test for.
For the sake of this example we will use the EUR/USD
Click on the EUR/USD symbol. You will be asked if you want to open or save the file. Chose to save the file. Remember the location where you saved it to.
Save the zip-file and unzip the file. You now have M1 historical data for the EUR/USD for more than 2 years.
Import Alpari data into MT4
How to import historical data in MT4
Open the test version of MT4. You will get 2 screens wanting you to open an account. Cancel both as we do not want any accounts for this test-version as previously stated.
In MT4 click Tools and History Center and look for the EUR/USD. Double-click the 1Minute button. There should be no data in this screen.
Now click the Import-button and go to the folder were you have saved the file
Be certain that you have selected the correct file-type (MetaQuotes files) When the data is imported, close the Import-screen with the OK-button. You now have the data imported in the History Center. You can close this screen with the Close-button.
Convert M1 data to the different time frames
Now we have to convert the M1 data to all of the other time frames (M15, M30, M60, M240,
M1440 and M10080).
To do this click on File => Open Offline and look for EUR/USD, M1. Select this and click the Open button. You now have a offline chart for the EUR/USD M1 on your screen. Change the Max bars for your History and your Charts: To do this click on Tools, Options, and Charts and add all nines (9999999) to your Max Bars.
Close this screen with the OK-button.
On the left side of your screen you have your Navigator screen. If not you can open this with CTRL N. Under Scripts you will see a script called “period_converter” Double-click on it. You will get a pop-up screen asking for settings.
To begin the conversion from M1 to M5, set the Variable ExtPeriodMultiplier to 5 and click the OK button. The screen will disappear and it will look like nothing is happening. But something is happening. In the background, the script is converting the M1 data to M5 data and it needs some time to do it. The script needs some time for the conversion so you have to wait at least 30 seconds before moving on to the next time frame. Do not give into the temptation of rushing through this process.
After the wait-time, double-click the script again. You see a warning-screen asking if you really want to stop the script. Say “Yes” Now you have the start-screen of the script again and you can use the next time frame (15). So change “ExtPeriodMultiplier” to 15 and after that repeat all this for the rest of the time frames. (5, 15, 30, 60, 240, 1440 and10080)
Restart MetaTrader 4
When complete, restart the MT4 application and now you will have 90% Modeling Quality for the EUR/USD the next time you test an Expert Advisor for MetaTrader 4
You have to repeat this procedure for every currency pair that you want to test.
If you do this, you will have as near perfect a back-testing ‘engine’ as you can get with MT4.