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):


Then 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. You’ll probably won’t need to follow the next steps listed here. Just follow the instructions listed on the Alpari’s historic data page and proceed to step 13 here.
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!

Leave a Reply

Your email address will not be published. Required fields are marked *

fifty five − forty eight =