LiteForex - Forex trading account from 1$

Thursday, January 03, 2008

MetaTrader History Data Importing and Converting Tutorial for Quality Backtesting

Backtesting MetaTrader expert advisors on historical data is a good way to test a strategy. But testing on the limited data supplied with MT4 installation gives a very poor quality of testing (usually below 50%). So, how to achieve a 90% quality in backtesting of MT4 expert advisors? It's not that hard really, just follow this simple tutorial and you will able to test any MetaTrader EA.

1. Download a new MetaTrader 4 installation and install it to a separate folder. Be advised that a good MetaTrader historical data take up a lot of disk space, so install it to a drive with at least 1-2 Gbytes of free space. For download MT4 installation I recommend official MetaQuotes site.

2. After you install your MT4, don't run it yet. Go to the folder you have installed it to. Go the 'history' folder there and delete all folders there (the actual folders names inside the 'history' folder may be different from those on these pictures):

3. Run the newly installed MetaTrader and open a free demo account with whatever broker it will be offering to you (official MetaQuotes installation offers random brokers for demo account opening in its MT4). Login to your account and close all open charts (if any).

4. Adjust the MetaTrader options to allow larger charts (more bars in history):
The close your MetaTrader.

5. Download a quality historical data for every currency pair you want to test your expert advisor on. I recommend Alpari History Center for this - download M1 data for each of the currency pairs you need.

6. Unzip the archive with M1 historical data somewhere. Rename it to comply with MT4 standard naming - i.e. EUR/USD M1 chart should be named EURUSD1.hst, GBP/USD M1 should be renamed to GBPUSD1.hst, etc.

7. Copy the renamed history file to your MetaTrader's 'history' folder into your broker's folder (overwrite if prompted):

8. Launch MetaTrader 4 again. Don't open any charts on-line, open your downloaded M1 chart offline (example shown for EUR/USD chart):

9. It might take some time for the actual chart to load, but it's OK. Now you need to convert M1 history to every timeframe you will need. For this you need to use a period_converter script which is a standard feature of all MT4 platforms. Run it from the Scripts tab and set its ExtPeriodMultiplier input parameter to the number of minutes in the desired output timeframe. For M5 enter 5, for M15 enter 15, for M30 enter 30, for H1 enter 60, for H4 enter 240, for D1 enter 1440, for W1 enter 10080, MN isn't convertible as there is no fixed amount of minutes in one month:

10. Wait for the script to finish its work (may take up some time; it's more than 2 years of data after all):

11. Repeat steps 8-10 for all timeframes you want to get.

12. Repeat steps 5-11 for all currency pairs you want to test your MT4 EAs on.

13. VoilĂ ! Now you can enjoy a 90% quality backtesting and test every expert advisor you want on the time periods of more than 2 years. Good luck with your trading!

Labels: , ,

AddThis Social Bookmark Button

8 Comments:

Blogger a1 said...

This comment has been removed by the author.

Saturday, January 05, 2008  
Blogger xma said...

very good manual! I have a queston.When I converted the 1H timeframe to 2H timeframe.How to choice 2H timeframe in strategy tester?I can select m1,m5,m15,m30,H1,4 daily but the 2H timeframe is not present in startegy tester,but i converted it and i see when i opening chart offline.
Sorry for my english .

Thanks

Saturday, January 05, 2008  
Blogger enivid said...

First, thanks for using this tutorial. Second, it's better create all timeframes from M1 timeframe. Third, unfortunately, there is no H2 timeframe in MT4, so you must use one of the standard timeframes...

Saturday, January 05, 2008  
Blogger xma said...

Thanks for your answer.
I interesing the visual mode in strategy tester ,while i see what happening on every each tick .When i runing expert advisor on 1H timeframe i dont see what happening in my custom timeframe.Have you any idea what can i do ,to fix this problem?


Thanks

Saturday, January 05, 2008  
Blogger enivid said...

Sorry, I don't use the visualization in strategy tester. Maybe there are no orders to draw?

Saturday, January 05, 2008  
Blogger xma said...

When i using the strategy tester i must select a timeframe(I can not select my custom timeframe)
I think so ,the only way that i see redrawing the chartis the visual mode.

Saturday, January 05, 2008  
Blogger xma said...

I have a new problem:) I try to open the 1M history date but in chart windows write me with big font WAIT,and not happening anything .I make all as your manual .
What i do wrong?

Saturday, January 05, 2008  
Blogger enivid said...

Did you rename it as mentioned in the tutorial? Did you copy it to the proper history folder?

Saturday, January 05, 2008  

Post a Comment

<< Home

FXOpen - Forex at its Best