Home
Search Forums
Keywords:
Search Titles Only
User Name:
Exact Match
Show Results As:
Advanced Options
Reply
 
Thread Tools Search this Thread
  #1  
Old Jun 20, 2006 5:49pm
soso_beton's Avatar
Geometric Trader
 
Member Since Feb 2006
3 Vouchers  331 Posts
Default MT4 Backtesting Threads

Use this thread to discuss MT4 backtesting stuff.


Index of MT4 backtesting information:

  1. Backtesting reliability: http://www.forexfactory.com/forexfor...06&postcount=2
  2. Historical data: http://www.forexfactory.com/forexfor...07&postcount=3
  3. Manual backtesting: http://www.forexfactory.com/forexfor...10&postcount=4
  4. Coders Guru documents on strategy testing: http://www.forexfactory.com/forexfor...0&postcount=15
__________________
-soso

Last edited by soso_beton, Jun 21, 2006 10:10am
Reply With Quote
  #2  
Old Jun 20, 2006 5:55pm
soso_beton's Avatar
Geometric Trader
 
Member Since Feb 2006
3 Vouchers  331 Posts
Default Backtesting reliability

It is a known issue that MT4 reliability of backtesting is questionable. How can one improve the reliability of MT4 backtesting?


mcboogs writes at http://strategybuilderfx.com/showthread.php?t=15309:

Quote:
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.

In another thread here on FF mackdodger discusses and provides solutions on MT4 backtesting reliability:

http://www.forexfactory.com/forexfor...ead.php?t=5585
__________________
-soso

Last edited by soso_beton, Jun 21, 2006 4:48am
Reply With Quote
  #3  
Old Jun 20, 2006 5:57pm
soso_beton's Avatar
Geometric Trader
 
Member Since Feb 2006
3 Vouchers  331 Posts
Default Historical MT data..

Alpari provides MT reliable data going a few years back. If you're serious abotut backtesting then you'll likely need it. Here's the link:

http://www.alpari-idc.com/en/dc/databank.php
__________________
-soso
Reply With Quote
  #4  
Old Jun 20, 2006 6:01pm
soso_beton's Avatar
Geometric Trader
 
Member Since Feb 2006
3 Vouchers  331 Posts
Default Manual backtesting

It is possible to perform manual backtesting (bar by bar). Here's how to do it:

- first disable chart autoscroll (right click on chart window -> Properties -> Common tab -> Uncheck chart autoscroll option.
- scroll back the chart to the point where you want to start. Don't peek while scrolling
- now you can play the chart bar by bar using F12.
__________________
-soso
Reply With Quote
  #5  
Old Jun 20, 2006 6:14pm
renasdad's Avatar
live trader
 
Member Since Mar 2006
Default

Quote:
Originally Posted by soso_beton
It is possible to perform manual backtesting (bar by bar). Here's how to do it:

- first disable chart autoscroll (right click on chart window -> Properties -> Common tab -> Uncheck chart autoscroll option.
- scroll back the chart to the point where you want to start. Don't peek while scrolling
- now you can play the chart bar by bar using F12.
I have always wondered how to do that. And it had to be that simple too.
__________________
JOHN 3:16
Reply With Quote
  #6  
Old Jun 20, 2006 6:16pm
renasdad's Avatar
live trader
 
Member Since Mar 2006
Default

Ok, here is a dumb question I am sure. Do I need an Expert Avdisor for the backtesting. I have read through things explaining how to do it and I am totally lost. I would really like to learn it though.
__________________
JOHN 3:16
Reply With Quote
  #7  
Old Jun 20, 2006 6:25pm
soso_beton's Avatar
Geometric Trader
 
Member Since Feb 2006
3 Vouchers  331 Posts
Default

Yep, you need to do one. You need to know programming. Do you have any programming knowleddge? Not necessarily MQ4 or trading related.

Anyhow, there will be a thread strictly dedicated to MQ4 programming. If requested then I'll look to put general programming resources for true beginners too!

Later edit: Actually here's a link to a thread that will code the Expert for you: http://www.forexfactory.com/forexfor...ead.php?t=5990
__________________
-soso
Reply With Quote
  #8  
Old Jun 20, 2006 6:41pm
witchazel's Avatar
Member
 
Member Since May 2006
1 Vouchers  304 Posts
Default

I have recently started programming my EAs in for testing. I cant figure out how to get MT4 not to give me profits on spreads.

Say i start usdjpy at 114.00 with limit of 20 and stop of 20 and 1 lot. it will say i got $200 if it hits limit, but i have a 2pip spread it should be $180.

This makes a huge difference when you add money management to the test (eg. i want to risk 1% aviablemargin a trade).
Reply With Quote
  #9  
Old Jun 20, 2006 9:46pm
renasdad's Avatar
live trader
 
Member Since Mar 2006
Default

You explained how to turn off the auto scroll. Now, how far back in time can a person go? I have up a 1 hr chart and I can only go back to March is that normal?
__________________
JOHN 3:16
Reply With Quote
  #10  
Old Jun 21, 2006 3:05am
soso_beton's Avatar
Geometric Trader
 
Member Since Feb 2006
3 Vouchers  331 Posts
Default

Keep pulling of the chart. After a little delay you'll see that it scrolls, basically it reads more historical data from the MT server you are connected to. It can go a few years back.

Quote:
Originally Posted by renasdad
You explained how to turn off the auto scroll. Now, how far back in time can a person go? I have up a 1 hr chart and I can only go back to March is that normal?
__________________
-soso
Reply With Quote
  #11  
Old Jun 21, 2006 3:22am
piccolo's Avatar
Trader and Programmer
 
Member Since Feb 2006
More than 10 Vouchers  850 Posts
Default

Quote:
Originally Posted by soso_beton
Keep pulling of the chart. After a little delay you'll see that it scrolls, basically it reads more historical data from the MT server you are connected to. It can go a few years back.
i don't have the time but somebody needs to write a simple article on historic data and period conversion.

on alpari you can find 1min data for last 2 years, you need to convert it to 5min, 15min, 1h and then you got yourself a chart. and so on..

Update: actually somebody just did it in this thread:
http://www.forexfactory.com/forexfor...ead.php?t=5585

haven't read it, though.
__________________
My wife singing.. http://www.youtube.com/watch?v=wU1pD4xPe2M&NR=1&fmt=18
Reply With Quote
  #12  
Old Jun 21, 2006 3:35am
renasdad's Avatar
live trader
 
Member Since Mar 2006
Default

Quote:
Originally Posted by soso_beton
Keep pulling of the chart. After a little delay you'll see that it scrolls, basically it reads more historical data from the MT server you are connected to. It can go a few years back.
When I try to go back in time, I scroll with the mouse. It goes back so far and it will stall out. Then it starts back at the beginning and I do it again. It keeps on going back to the same spot.
__________________
JOHN 3:16
Reply With Quote
  #13  
Old Jun 21, 2006 3:46am
piccolo's Avatar
Trader and Programmer
 
Member Since Feb 2006
More than 10 Vouchers  850 Posts
Default

Quote:
Originally Posted by renasdad
When I try to go back in time, I scroll with the mouse. It goes back so far and it will stall out. Then it starts back at the beginning and I do it again. It keeps on going back to the same spot.
you need to import historic data to go futher back. take a look at my previous post.
__________________
My wife singing.. http://www.youtube.com/watch?v=wU1pD4xPe2M&NR=1&fmt=18
Reply With Quote
  #14  
Old Jun 21, 2006 3:56am
renasdad's Avatar
live trader
 
Member Since Mar 2006
Default

Quote:
Originally Posted by piccolo
you need to import historic data to go futher back. take a look at my previous post.
Thank you,
Will have a look when I get home.
__________________
JOHN 3:16
Reply With Quote
  #15  
Old Jun 21, 2006 5:29am
soso_beton's Avatar
Geometric Trader
 
Member Since Feb 2006
3 Vouchers  331 Posts
Default Coders Guru documents on strategy testing

Coders Guru documents on strategy testing
__________________
-soso
Reply With Quote
Reply

1 Trader Viewing This Thread (0 are members)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
MT4 EA backtesting n4btb Programming Discussion 2 May 14, 2009 6:11am
Setting up MT4 for backtesting D_Trader Programming Discussion 6 Apr 9, 2009 6:32am
MT4 Backtesting Very Slow rowdy Programming Discussion 1 Apr 6, 2009 10:26pm
MT4 Backtesting... mwfromva Rookie Discussion 1 Sep 12, 2006 12:54am
MT4 Backtesting and spreads witchazel Rookie Discussion 0 Jun 17, 2006 5:43am