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.
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 in the screenshot):
4. Run your MT4 again. Adjust the MetaTrader options to allow more bars in chart history via Tools->Options->Charts:
5. Go to MT4 History Center (
6.
7. Click Download — a warning message may appear (click OK if it does):
8. After the download process ends, you will see some M1 data there:
9. Go to File->Open Offline and open the M1 chart you just downloaded the data for:
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:
11. Check the Experts tab of the Terminal panel to see that the script finished its work successfully:
12. Now, if I backtest some EA on an M30 timeframe with Every tick model, it shows 90% modeling quality:
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
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.