Open live account Rule based trading platfom and supporting community

Go Back   StrategyBuilderFX > Main Discussion Forum > General discussions
Register FAQ MQL Files Calendar Mark Forums Read

Community Navigation

MT4 Mobile Trader
Mobile trading (m-trading) — controlling of trading account via mobile devices such a cellular phone or a PDA (Personal Digital Assistant).Wireless access technologies and GPRS provide access to the Internet.




Search Forums
 
» Advanced Search

Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Old 19-09-2005, 02:35:25 PM   #1
mcboogs
Registered User
 
Join Date: Jul 2005
Posts: 31
Rep Power: 6 mcboogs is on a distinguished road
MT4 Backtesting F.A.Q.

I decided to write up this little tutorial, because backtesting different systems comes up very often in threads on this forum. There seems to be a lot of confusion about reliability issues and how to go about achieving the most accurate possible results. I am not a programming or trading guru, but I believe I can provide a helpful little FAQ on backtesting using MT4.
Good backtesting is important when considering a system-trading approach, because you want to have some idea of the feasibility of your idea before you go live with it [at least I do]. If you're backtesting with a 50% model quality, eh... you can't really be sure what's going on. If you have a 90% modeling quality, you can have more confidence on how your system actually would have performed.


+=========================+
|MCBoogs' MT4 Backtesting FAQ v1.0 |
+=========================+

Contents:
- Section 1: Is MT4 Backtesting Reliable?
- Section 2: Downloading/Importing/Converting 1M Data
- Section 3: Configuring the Backtester
- Section 4: Other Issues


Section 1: Is MT4 Backtesting Reliable?

This question often gets pretty heated and people even get to the point of flaming each other about it. Backtesting in MT4 can be reliable, but its reliability is contingent upon the data you are backtesting on. Demo account data that is streamed in through a demo account broker has gaps, holes, and is basically not suitable for testing.
When backtesting, you want to use the EVERY TICK MODEL and have accurate 1M data to get the most accurate test possible. The 1M data is important, because the EVERY TICK MODEL uses whatever the smallest available timeframe available is and "fakes" the movement of price within the smallest available bars. Having 1M data allows for the fractal interpolation within bars to occurs only within the very narrow range of 1M bars.
The easiest [and only] solution to this is to use good 1M data. The most complete data you can get [at least for free] is from Alpari's Databank. They have data in MT native format, on the 1M timeframe back through mid 2004. However, setting up the data for use requires some doing.


---------------------------------------------------------------------------


Section 2: Downloading/Importing/Converting 1M Data

(1) You need to modify MT4 to allow for more bars. Go into the Tools Menu, then go to Options [or just hit C+O]. Go into the charts tab and put in 9999999999999 for bars in history. MT4 will default to whatever it's maximum is.

[Note: The reason MT4 has a limited bar count to begin with is because more bars (particularly when used in backtesting models) means MT4 is going to eat up more HD space.]

(2) Download the 1M data from Alpari's Databank in whatever currency[ies] you're going to test on.

(3) Import the data into MT4 using the History Center. Go to Tools => History Center [or push F2]. Make sure you import it in proper currency and in the M1 timeframe. You don't want EURUSD data being important into USDCAD for instance.

(4) Convert the data using the period converter script included in MT4 [you only have 1M bars right now]. You have to open offline charts to do this.
-Go to the File Menu, then Open Offline, select the 1M data of the currency you need to convert. A chart will pop up with that data.
-Then drag & drop the period_converter script onto the offline chart. The ExtPeriodMultiplier int that you can modify is the multiplier you are applying to the chart. So making it 5, will convert 1M data into 5M data.
-For simplicity's sake, you need to run the period converter with the following integers to get all the backtesting timeframes: 5,15,30,60,240, and 1440.

[NOTE: you can also convert 1M data to timeframes not native to MT4 if you want to do some indicator analysis or something on another timeframe.]

Congratulations, you have now imported and converted data into MT4. Now, for the sake of illustrating one of my earlier points, open up a currency you have imported data on. Look at the difference in the bars from the downloaded data as opposed to data streamed in from a Demo broker [So, if you downloaded 1M data from July 04 to August 05, look at the chart at August 05's end and September 05's beginning]. You will notice that the bars (on every time frime if you have converted them properly) from your downloaded time period will be more complete.


------------------------------------------------------------------


Section 3: Configuring the Backtester

Now that you've succesfully imported complete data, there are a few more things you need to do to run a reliable backtest.

(1) Check the recalculate option the next time you run a backtest, because you need the backtester to utilize your shiny new happy data (which it won't do unless you tell it). Anytime you import new data, you need to recalculate (I recalculate every few tests just to feel safe, maybe its a reflection of internal confidence problems, but that's for another FAQ).

(2) Check the use date option and set the date range only over a time period where you have good reliable data. This way you're only backtesting the good stuff. It will be reflected in the modeling quality percentage.

(3) Make sure the model is set to EVERY TICK. If you're not, all this hard work we just did was for nothing. I addressed why we do this earlier in the FAQ.


------------------------------------------------------------------------


Section 4: Other Issues

MT4 is a work in progress, sometimes there are strange bugs that crop up in backtesting. However, usually when you think you have a bug on your hands, there is something wrong with your code. I can't emphasize enough how important debugging is. If you have problems, check your code first because it's probably the problem. If you really think you have a legit bug on your hands, post it to the MT4 forums.
Because you are not actually backtesting on every tick that happened [you are dealing with an interpolation on 1M data], it is still not a perfect reproduction of what actually happened in the markets. Because of this, 1M and 5M scalping EAs that get in and out of trades really quickly will run into some problems just because of this limitation. The longer timeframe you are trading on, the less likely your testing is to be hampered by this.
Well, that's all I can think of now. I read this over, I think I made everything clear and have the steps outlined correctly. If you notive a mistake, let me know, and I'll correct it in my next version of the MT4 Backtesting FAQ.


Acknowledgements:
I learned most of what I know about MT4 and trading in general from these forums and others like it. Thanks to all the people who contribute that have provided me with useful tidbits of information. There are too many names [and some of them are weird, have lots of numbers in them, etc.] to list, but a serious thanks to all the StrategyBuilder contributors out there.
Best of luck in the markets everyone.
mcboogs is offline   Reply With Quote
Old 19-09-2005, 03:02:40 PM   #2
Shimodax
Registered User
 
Shimodax's Avatar
 
Join Date: Aug 2005
Posts: 349
Rep Power: 5 Shimodax is on a distinguished road
Re: MT4 Backtesting F.A.Q.

Hi!

I've tried Alpari this weekend but wasn't able to import the MetaTrader format. It did work with MetaStock (Ascii) format though.

Are you sure it works with MT native format (the files seem to be MT3).


Markus
Shimodax is offline   Reply With Quote
Old 19-09-2005, 04:52:50 PM   #3
mcboogs
Registered User
 
Join Date: Jul 2005
Posts: 31
Rep Power: 6 mcboogs is on a distinguished road
Re: MT4 Backtesting F.A.Q.

Shimodax,

You can definately use the MT format, I do and it works fine. When you go to import the data in the HIstory Center, make sure that you change the file type it is looking for to the Metaquotes file format.

-MCBoogs
mcboogs is offline   Reply With Quote
Old 19-09-2005, 06:27:54 PM   #4
Shimodax
Registered User
 
Shimodax's Avatar
 
Join Date: Aug 2005
Posts: 349
Rep Power: 5 Shimodax is on a distinguished road
Re: MT4 Backtesting F.A.Q.

Will try again (I think I missed the file type selection .... I did get the file in the file requester by entering "*"). Thanks for the hint.


Markus
Shimodax is offline   Reply With Quote
Old 21-09-2005, 01:56:32 PM   #5
Dae
Registered User
 
Join Date: Apr 2005
Posts: 17
Rep Power: 0 Dae is a glorious beacon of light Dae is a glorious beacon of light Dae is a glorious beacon of light Dae is a glorious beacon of light Dae is a glorious beacon of light Dae is a glorious beacon of light
Thumbs up Re: MT4 Backtesting F.A.Q.

A big Thankyou.

Excellent writing!!
Dae is offline   Reply With Quote
Old 21-09-2005, 05:21:38 PM   #6
bubo
Registered User
 
Join Date: Sep 2004
Posts: 48
Rep Power: 11 bubo is a glorious beacon of light bubo is a glorious beacon of light bubo is a glorious beacon of light bubo is a glorious beacon of light bubo is a glorious beacon of light bubo is a glorious beacon of light
Re: MT4 Backtesting F.A.Q.

Quote:
Originally Posted by Shimodax
Hi!

I've tried Alpari this weekend but wasn't able to import the MetaTrader format. It did work with MetaStock (Ascii) format though.

Are you sure it works with MT native format (the files seem to be MT3).

Markus

I also found that I had to import the files into MT3, and then export them as csv files, and then read them again by MT4.

Let me know if there is an easier way, I couldn't see one.
bubo is offline   Reply With Quote
Old 21-09-2005, 05:40:32 PM   #7
bubo
Registered User
 
Join Date: Sep 2004
Posts: 48
Rep Power: 11 bubo is a glorious beacon of light bubo is a glorious beacon of light bubo is a glorious beacon of light bubo is a glorious beacon of light bubo is a glorious beacon of light bubo is a glorious beacon of light
Re: MT4 Backtesting F.A.Q.

What exactly does the Strategy Tester do or not do when the Recalculate button is not checked?

Is it only data that is used, or some of the parameters as well?

There is little information about it, and I also feel uncomfortable with this feature - I always check the box 'Recalculate' because I want to ensure there is no parameters from previous tests being used.
bubo is offline   Reply With Quote
Old 22-09-2005, 05:43:37 AM   #8
mcboogs
Registered User
 
Join Date: Jul 2005
Posts: 31
Rep Power: 6 mcboogs is on a distinguished road
Re: MT4 Backtesting F.A.Q.

Bubo,

The recalculate button only applies to the data the backtester uses to run its result. If checked, it deletes the cached data and generates a new testfile with the data present in the history center. Recalculating before every test isn't a bad idea, because that ensures your test will be run with your most current data, although it is time comsuming.

-MCBoogs
mcboogs is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump



Contact Us | StrategyBuilderFX MT4 Trading Platform | Archive | Privacy Statement | Top