Update: See this post for a newer (and I would argue better) method.
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.
http://www.alpari-idc.com/en/dc/databank.php
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
M1_EUR/USD.hst.
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.
very helpful, thanks a lot 🙂 but I didn’t understand how to “delete” the demo account. It is inactive at this moment (30 days trial expired), but my history still gets cancelled when I close and reopen MT4. Can you help? thanks, Paolo
If you look at the right hand column where it says “Account” make sure you right click on top of any account numbers that show up and chose delete.
However I have good news for you Paolo. The procedure outlined in this post is somewhat obsolete. Recently the makers of MetaTrader 4 have decided to provide direct market data feeds which can be easily downloaded from their servers. All you have to do is go to Tool – History Center – and select the currency pair that you want and click Download.
However, please keep in mind that you should STILL dedicate an account only for backtesting. DO NOT run a demo account or live account on the same MT4 install that you use to backtest. It will corrupt your history data and thus give you false backtesting results.
I plan to eventually write a post about this new method. You can still use the method outlined in this post but it is more cumbersome and involves more work.
Dear Guru’s,
i need help. I follow your steps and i convert 1M GBPUSD to 30M and 1H chart. I leave the computer at least 10 minuts for every conversion. On the end i restart metatrader and open charts. Datas looks o.k. and the time frame was complete.
But when i start EAs (profesional one, which i am also using daily and i was testing on alpari download demo account ) i got only 2 or 3 trades. I know that this EAs should work because they work with worse model quality.
Can you sugest to me what to do or check or maybe correct …??
Kind Regards,
Teodor Lango
Hi Teo. Follow this link:
http://alansforexblog.com/2008/04/16/new-method-to-achieve-90-modeling-quality-in-mt4s-strategy-tester/
this is the new and preferred method to download the latest backtesting price data.
As for your EA not trading as often as you expect, well, that depends. Do you mean to say that on higher time frames it doesn’t trade as often?
Bear in mind that the time frame you use DOES affect the frequency of trades being opened. This is valid for the majority of EAs. What time frame are you using by the way?
First though I’d suggest you visit this link:
http://alansforexblog.com/2008/04/16/new-method-to-achieve-90-modeling-quality-in-mt4s-strategy-tester/
If you need further help please start a thread in my forum over here:
http://www.moneyguruforum.com/forex/baby-pips/
free of charge ex4 decompiling
Hi there folks … if anybody needs a decompiling of ex4 file just drop me an email at ex4source@gmail.com . It will take 1-2 days until you get the source code.
lol, free eh? :p that’s a pretty clever way to get your hands on tons of commercial EAs.
Hi,
I am trying to get 90% on the EUR/USD pair but keep getting 25%. I used the original method outlined here and also the new method – but always have 25% quality only. Can anyone help?
Thanks!
Jack did you first read this post?
http://alansforexblog.com/2008/04/16/new-method-to-achieve-90-modeling-quality-in-mt4s-strategy-tester/
??
Hi, Yes I did read the post on directly downloading the data from MT4. I’ve also used an exclusively separate instance of MT4 for testing, but still have the same issue – 25% modeling quality on EUR/USD m1 EA test. Any further guidance would be much appreciated. Thank you so much!
Jack
Hello again,
By the way, I’m using the FAP Turbo EA. I read in your portfolio that you use the original FAP to trade. This is why I’m so interested in getting 90% on EUR/USD M1, because that’s the long term FAP Turbo strategy.
Thanks again,
Jack
Jack I forgot to mention that you cannot get the modeling quality any higher than 25% on the M1 chart. Try it on a higher time frame and you’ll see that you will get typically 90% modeling quality, but you’ll NEVER be able to get that on the M1 time frame.
Yep, I use both now. But for now only the original FAP is running live.
You know so far I’m not so impressed with the long term strategy of FAPTurbo. I think the scalper strategy is much better so far.
Btw, have you joined my Forex Autopilot Forum yet? 🙂
http://www.forexautopilotforum.com
We’ve got a ton of friendly and knowledgeable FAP users there. There is free support and free custom settings available there as well.
Hi there,
Oh man no 90% on M1, then how do the original FAP guys show 90% quality on their backtests?
Thanks sooo much for the link to the FAP forum. I’ll surely join!
Thanks again for your help! you’ve really got a great blog here.
Jack
they got 90% by running the backtest on the M5 time frame…much as what I did when I backtested it.
And thanks 🙂 I’m glad you like my blog.
I just found this website recently when a buddy suggested it to me. I have been a regular reader ever since.
Hi Alan,
I went to http://www.alpari-idc.com/en/dc/databank.php
to download the one minute data for Euro/USD. But the page that comes up tells you to download Metatrader 4 from Alpari, and then download data from the History tab inside Metatrader. However, when I do this, a screen comes up saying I am downloading historical data from Metaquotes. Does Alpari still offer historical data, or are there any other brokers who offer this? Thanks.
Rebecca, Alpari no longer offers M1 data, but you can use this method which will work with any broker’s mt4 platform:
http://alansforexblog.com/2008/04/16/new-method-to-achieve-90-modeling-quality-in-mt4s-strategy-tester/
As far as I know there are no other brokers that offer their own historic price data. Actually there is one, Dukascopy, but they do it in a format that is not easily imported into MT4 and it takes a bit of effort to get it up and running with MT4. I am going to write a tutorial about it sometime soon. Here is a link to their price data page:
http://www.dukascopy.com/swiss/english/data_feed/historical/?ibref=415
*the good thing about this is you can achieve 99% modeling quality, unlike 90% with the data downloaded from MetaQuotes*
Do you trade the FOREX market, and if so, do you trade cash or futures?
I trade spot forex, which in your sense means “trade cash”
When we open up the 1 min chart of imported data to convert to higher timeframes, we are limited to only the last 2 months past, even with chart bars set at max. This means we cant convert the data from more than 2 months ago. Any way to overcome this?
Well that’s not right. That means that the history data was not downloaded completely. Try redownloading the history data again and also try another MT4 platform just in case there is something odd with your existing one.
Let me know if that works. If not start a thread in the Backesting & Optimization section of the Forex Nirvana forum and I’ll do my best to help you.
http://www.forexnirvana.com is the link to the forum
I love it when individuals come together and share thoughts.
Great blog, keep it up!