Multiple Time Frame EA random error

 

Hello,

I've coded an EA that among other things calculates iMA from multiple time frames in order to make decisions. When I try to backtest it with the Strategy Tester I randomly get a ZERO result from the iMA function at the very first bar. I then retry it without any changes and usually after the 2nd or the 3rd attempt it does run fine until the end. Could anybody point why the Strategy Tester is not running correctly from the first time?

Thank you.

Eddie 

PS: I've gathered tick data using Tickstory. 

 
Make sure that you start your back tests optimizer at a date that is n bars later than the first bar of your data (chart) and check the first values..
 
EAlbuquerque:

I've coded an EA that among other things calculates iMA from multiple time frames in order to make decisions. When I try to backtest it with the Strategy Tester I randomly get a ZERO result from the iMA function at the very first bar. I then retry it without any changes and usually after the 2nd or the 3rd attempt it does run fine until the end. Could anybody point why the Strategy Tester is not running correctly from the first time?

PS: I've gathered tick data using Tickstory. 

Two important points to consider.

  1. Just as "@gooly" pointed out, since you are using a 3rd party generated FXT file, make sure your starting test date is well beyond the first date of the FXT data to compensate for the Period length of your iMA on multiple timeframes.
  2. Since you are using Multi-timeframe, HST files are just as important as the FXT file. So ...
    1. When generating files in TickStory, produce both FXT and HST files.
    2. Normally, FXT are set to read-only by TickStory, but not the HST files. So, before starting MetaTrader, make sure to set both the FXT and the HST files to read-only. If you don't do this, HST files will be overridden by Broker data and will not be in sync with the FXT data.
 

Gooly and FMIC,

Thank you for your comments. I'm downloading new pairs as I write this to make sure they're "fresh" and will mark the FXT and HST files as read-only before starting MT4 again. My MT4, however, is used only for the Strategy Tester - in fact I've never connected it to the broker not only once (not even to open a demo account). So I'm pretty sure my Tickstory history files are intact. During the weekend I did a test: if I rollback my EA to a previous version when it didn't look into multiple time frames it runs ok. And I must also stress that the EA with multiple time frames does run OK after 2nd or 3rd attempt (I just click "start" again...). It's just annoying as this is to be delivered to a client who will certainly complain...

Thank you again for your help, I'll post again after trial with the new paris. 

PS: I downloaded 2 years of data and I"m just testing on the last 12 months using M5 and H1 and looking back no more than 32 bars. So my history is indeed enough.

Reason: