$ £ ¥
¥ £ $

MetaTrader Historical 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 default data available in your 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 isn't that hard really. Just follow this simple tutorial and you will able to test any MetaTrader EA with at least 90% modeling quality.

This tutorial has been compiled to provide accurate information regarding 90% vs 99.9% modeling quality and to present an easy method of getting quality historical data in your MT4 platform.


It is recommended to use a separate installation of MT4 to set up quality backtesting data there and to avoid it being overwritten with potentially flawed broker's data.

1. Download a new MetaTrader 4 installation and install it in a separate folder. Be advised that a good MetaTrader historical data take up a lot of disk space — expect it to take up about 1 GB of free space per two years of data. To download an MT4 installation, I recommend choosing one of the MT4 Forex brokers because you no longer can download MetaTrader 4 from the official MetaQuotes website.

2. Run the newly installed MetaTrader and login to your broker's demo account. Now, close all open charts.

3. Go to the menu File->Open Data Folder. It will bring up the folder with all the platform's data. Then close the platform.

MT4 - Open Data Folder

3. Open the history subfolder in the platform's data folder and delete everything there (the actual contents of your history folder may differ from those you see on the screenshot):

MT4 History Folder Deleting Previous MT4 History

4. Run your MT4 again. Adjust the MetaTrader options to allow more bars in chart history via Tools->Options->Charts:

MT4 History Options Set MT4 Historical Bars Number to Maximum

5. Go to MT4 History Center (F2 on your keyboard) to download 1-minute historical data for every currency pair you want to test your expert advisor on.

MT4 History Center Menu

6. Double-click the M1 timeframe for the currency pair of your choice (it should show empty data):

MT4 History Center Menu

7. Click Download — a warning message may appear (click OK if it does):

MT4 - History Center Download Warning

8. After the download process ends, you will see some M1 data there:

MT4 - History Center - M1 Data

9. Go to File->Open Offline and open the M1 chart you just downloaded the data for:

MT4 - File->Open Offline Menu MT4 - Opening Offline M1 Chart

10. A chart will open. Find the PeriodConverter script in Scripts via Navigator panel (it is a default script provided by MetaQuotes). Run it on the chart, setting the Period multiplier factor depending on the timeframe you need for your test. Here, you see it set for M30 conversion:

MT4 - Running Period Converter Script

11. Check the Experts tab of the Terminal panel to see that the script finished its work successfully:

MT4 - Checking Period Converter Script Result

12. Now, if I backtest some EA on an M30 timeframe with Every tick model, it shows 90% modeling quality:

MT4 - 90% Modeling Quality Attained in Backtest Report

Since Build 940 of MetaTrader 4, 90% is maximum modeling quality attainable in backtests without resorting to custom tick data hacks. 99.9% modeling quality can be achieved by using third-party tick data converted to MetaTrader's custom .fxt format.

Generating custom .fxt is a rather complex process and the steps differ depending on the tools you decide to use. I recommend using QuantDataManager from StrategyQuant because it is free, lets you download Dukascopy tick data for long periods of time, and converts the downloaded .csv tick data into .fxt and .hst history data used by MetaTrader 4. Other similar tools include Tickstory and Tick Data Suite from Birt Ltd.

You can discuss this and other methods of getting high-quality historical data for backtesting in MetaTrader 4 in our forum dedicated to the MT4 platform.

Did you know? MetaTrader 5 natively supports backtesting on real ticks data. Even if your MT5 broker doesn't provide quality real ticks data for the period and the currency pair you would like to backtest on, you can switch to a broker that does provide such data. There is rarely a point in using third-party data providers with MetaTrader 5.