Greetings everyone!
In today’s post I’m going to show you how you can get 99% modeling quality when backtesting using MT4’s “Strategy Tester.” If you’re a MT4 backtesting veteran you no doubt know that using regular M1 historic data the highest modeling quality you can get is 90%, but what you may or may not know is that the accuracy of your backtests can be pushed even higher, BUT you need raw tick data.
How does one obtain such tick data? Well, I asked myself that very same question, and I’ve looked everywhere for a free source of historical forex tick data and after extensive searching I found it. The only problem is that the tick data is not readily usable by MT4 and as such requires a rather elaborate process of conversion and also a few other tricks to force MT4 to use the converted tick data. That’s where this tutorial or “how-to” comes in. So pay close attention as you MUST follow each step precisely.
You may be asking yourself why would one want to achieve a higher modeling quality level. The answer has to do with scalping. When backtesting an expert advisor that does not attempt to scalp the market the default MT4 history data provides an acceptably accurate level of simulation. However when you’re trying to backtest a scalping EA even the slightest variation in the price feed can strongly affect performance.
UPDATE: previous content removed. If you want the full tutorial you can find it on the following website:
Happy backtesting everyone!
Cheers,
Alan
Hi,
Just to leave a BIG thank you for this fantastic tool.
Best Regards,
Pedro Gonçalves
You’re welcome Pedro. Good luck with your trading!
THANK YOU!!!
Man, I’m so happy.. I have an EA that is working for me, however, I always had doubts about the backtests… The result for 90% of model quality data is interesting, however, with 99% is amazing!
Now I’m a guy very very happy with my EA… Low DD, High Profit Factor, etc.
Best regards,
Dan
I’ve followed all the above steps (read thru the page twice or thrice to ensure that I’ve done it correctly) but I still do not get 99% modelling quality. Always it shows 90% 🙁 What could be the problem ?
did you use the proper loader..? If you don’t use the loader MT4 will delete the history files when it starts up…
also make sure you use MT4 build 225 or 226
hi, I was using mt4 build 226 and used the proper loader for that version (http://alansforexblog.com/files/226_loader.zip)
I read thru your instructions again and it looks like the issue is because of size restriction of .fxt file . The EURUSD.csv file the process script had generated was of size 5.14 GB but the EURUSD1_0.fxt (generated by Dukascopy2FXT) which is now in tester/history is only 1.99 GB .
I wanted to test my EA in 1 min charts (for last 2-3 years) so for the 3rd step (ie, “Open a chart for the pair that you have data for”) I’d changed the chart timeframe to M1 before executing Dukascopy2FXT script. Could that be a problem?
Hmm, not sure if that makes a difference..the script does the same job (ie uses the tick data) either way. But if you find out otherwise please let me know. When I did the conversion process I did not change the time frame on the chart. I would just simply open a chart, load the script and tell it what time frame I want to convert and watch it run.
Hi,
Maybe a stupid question, but is this also required for 15M> charts? I’m letting a programmer write me an EA, and i only want to use it for 15M and higher charts. I got CSV files from my own broker (http://www.gomarketsaus.com/historic-data.html) provided for free. I’d like to make a backtest based upon that data. How do i do that?
Sorry if it’s just a stupid question, but i’m new to backtesting like this. Thanks in advance!
Peter.
Yep it’s required for any time frame charts (H1, M30 etc).
The only difference in the procedure outlined above and what you need to do is that you’re going to have to substitute your gomarkets CSV data for the dukascopy data. So you’re still going to have to convert it into FXT format.
And don’t worry, it’s not a stupid question..never be afraid to ask a question!
Cheers,
Alan
Alan,
Thanks for your quick reply!
So, i’ll work myself trough this part, and see if i can get it working, pray for me ;-).
Peter.
Peter I’m sure you’ll get it going just fine. If you don’t and run into any problems join me at the forex nirvana forum…go to the backtesting and optimization section.
I’m trying to download data using the php script but it gives me an error after a while..I took a screenshot of the message here: http://i37.tinypic.com/34o4jm0.jpg
Ouch, that means there is a problem with Dukascopy’s tick data server. I do hope they haven’t stopped offering this service.
I’d say wait a few days and if the problem persists, then umm…time to look for other alternatives.
Okay so it turns out that it keeps downloading data even after the error message. After the message nothing happens for a few minutes but after that it’s up and running again.
Whew..that’s a relief. I was afraid there for a second that they’ve stopped offering the tick data for free.
Great.
However two very important issues:
Ducascopy prices will be different from your broker prices. Not only price levels but also price action may be different (e.g. your broker engulfing pattern could not exist on Ducascopy candles or a spike here while no spike there).
Not only the timezone but also DST matters.
You need to know your broker feed timezone and DST settings.
Most of them fall in GMT+0 to GMT+3 and no DST, European DST or US DST schemes.
Unfortunately you cannot get if from MT4 feed. Brokers don’t publish their feed time bases – you have to ask customer support believe me they’ll be baffled with your question…
At the end you may need a piece of software to recalculate everything accordingly (could be MT4 script).
ALX
Is there a way to have just 1 FXT file per timeframe?
For example, I have 4H EURUSD data from 2007-2010 using your guide, but I have to limit it 3 FXT files that are ~2GB each (2007-2008, 2008-2009, and 2009-2010). When I backtest, metatrader doesn’t see the other 2 FXT files and only sees the one with the default name.
If I want to backtest from 2007-2010, I have to run 3 different tests.
I’m afraid there is no way to get around MT4’s strategy tester max file size limitation – I could be wrong, but I’m reasonably sure of this as I researched this heavily before attempting it.
And technically speaking all the FXT files are PER time frame. Meaning for each time frame you wish to test on you have to create a .fxt file for..ie convert the eur/usd cvs file to fxt using the convert script.
What’s the difference between 99% and 90% modelling quality? Does 90% mean that metatrader doesn’t know what to do for 10% of the ticks and fills it in using an algorithm, so 99% would mean that it’s 1% different from real time data?
Well as far as I know the modeling quality is not necessarily the be all end all. What is more important is the QUALITY of the tick data that the MT4 backtester uses. If the backtester is given crap data it will do it’s best to model or extrapolate as much tick data on higher time frames as possible but the end result will NOT be as good as say if you give it high quality TICK data as in the case with the Dukascopy tick data. The reason it says it achieved 99% modeling quality with Dukascopy tick data is that it has to do a LOT LESS modeling or “guessing” extrapolating or whatever you wish to call it thatn with MT4 data downloaded directly from MetaQuotes or your broker.
So the answer to your question is that 90% doesn’t necessarily mean that it doesn’t know what to do with 10% of the tick data..this is the wrong way of interpreting how the MT4 backtester works.
This may help:
Modelling quality’ is calculated according to the following formula:
ModellingQuality = ((0.25*(StartGen-StartBar) + 0.5*(StartGenM1-StartGen) + 0.9*(HistoryTotal-StartGenM1)) / (HistoryTotal-StartBar))*100%;
where:
* HistoryTotal – the total amount of bars in history;
* StartBar – the number of bar with which the testing was started. Modeling starts at at least 101st bar or the bar corresponding with the initial date of test limits;
* StartGen – the number of bar with which the modeling on the nearest timeframe started;
* StartGenM1 – the number of bar with which the modeling on minutes started;
at that:
* The distance between the beginning of modeling of databases for the nearest timeframe and the beginning of modeling on the nearest timeframe data has a weighting factor of 0.25;
* The distance between the beginning of modeling on the nearest timeframe data and the beginning of modeling on minutes has a weighting factor of 0.5;
* The distance between the beginning of modeling on minutes and the end of history data has a weighting factor of 0.9;
The following colors are used in the color diagram:
* Lime – modeling on minutes
* Deeper green colors show modeling on large timeframes
* Pink color – pure fractal modeling of the databases of smaller timeframe
* Gray color – modeling limitation by date
From the formula you can see, that 90% is the maximum modelling quality possible.
I should qualify that by saying that this is only with default data which is based on M1 data…if you give it raw tick data like with the Dukascopy tick data it has more data to work with therefore the accuracy is higher.
@ Alx – comment #16
“Ducascopy prices will be different from your broker prices. Not only price levels but also price action may be different (e.g. your broker engulfing pattern could not exist on Ducascopy candles or a spike here while no spike there).”
Forget about your broker’s prices. Your broker’s prices is not even relevant. When you backtest this you are using DUKASCOPY’s price data and thus naturally price action will be different.
“Not only the timezone but also DST matters.
You need to know your broker feed timezone and DST settings.
Most of them fall in GMT+0 to GMT+3 and no DST, European DST or US DST schemes.
Unfortunately you cannot get if from MT4 feed. Brokers don’t publish their feed time bases – you have to ask customer support believe me they’ll be baffled with your question…
At the end you may need a piece of software to recalculate everything accordingly (could be MT4 script).”
Once again, stop thinking about your broker. Your broker does not come into the picture. You are simply using your broker’s MT4 platform to backtest USING DUKASCOPY’s DATA..which is what matters in the end. Dukascopy’s data is GMT 0 based with no DST.
Always remember that when it comes to running this type of backtest whatever broker’s platform you happen to be using is irrelevant.
However if you wish to actually run the EA you backtested with Dukascopy data on a specific broker then you probably will notice a different in performance/behavior as naturally your broker has a totally different price feed.
Using Dukascopy’s tick data is only useful in the sense of seeing what potential the EA has under as ideal as possible market conditions.
So once again when you backtest with Dukascopy data the GMT is 0 and whatever your broker’s price feed GMT setting happens to be is TOTALLY irrelevant.
hi,
Great article!
i have 3 short questions:
1. dukascopy are working with Mt4. can i download a mt4 demo and download from history center. will it give 99% quality?
2. do i have to do this process every month to get new and updated data?
3. how can i get 1 minuite data for sp500 for mt4?
1) No, Dukascopy does not offer the MT4 platform yet.
2) Yes if you want to have absolutely the latest history data. You would have to run the download dukascopy data script as often as you want to download newer data.
3) For this I’m not sure – at least not sure where you can get it for free. I’ sure there are paid solutions out there though…maybe esignal? I dunno, Google and I’m sure you will find tons of companies offering tick data for s&p 500
Hi, thank you for this wonderful tool, however, I generated the tick data with 3 pips spread and my EA behaved like it did with 4 pips spread in 90% quality. Also, when I ran this code:
Print(Ask – Bid);
return;
it returned 0.0004. Is that some bug?
Regenerated it with 2 pips spread, it is now returning 0.0003… I would like to be 100% sure with the backtest, can you investigate please? Thank you very much
Ok, found out… you need to change the 0xFC offset anyways, as MT4 generates new FXT in /tester/history/ folder – so you need to change the spread in a hex editor anyways, the Spread setting doesnt help anything
I guess I’m too late in responding. Glad you found out a solution.
I created this article awhile back. Shows how to get excellent modeling in MT4.
http://www.jeremywhittaker.com/2010/12/28/setting-up-metatrader-for-better-backtesting-quality/
I cannot find the article on the Birt’s EA Review website. Can anyone help me? A link maybe? Thanks in advance.
http://eareview.net/tick-data
enjoy…
birt is selling his work 100$ now ,we need other options
Hmmm, I agree. Other alternatives would be nice. I had to buy Birt’s solution as the old manual method is a bit cumbersome and doesn’t seem to work as well as with his custom hacked version of MT4 with the preloader. Plus he’s charging a monthly subscription which can get pretty expensive on a yearly basis.
I’m putting my money on MT5’s backtester which is supposed to be much better. I just gotta get my EAs updated to mt5 which could be a pain.
There’s a tool called ‘Tickstory’ that will allow you to generate MT4 backtest files:
http://www.tickstory.com