What causes this error in the tester?

 

Hi

I seem to be running into this backtesting issue time and time again, and was wondering if there is anything I can do, or perhaps is there anything I am doing wrong.

Basicall when calling this code on the tester its returns I value of over 1000:

 

iBarShift(Symbol(),Period(),iTime(Symbol(),PERIOD_W1,0),false);

Have I done something wrong there because the returned value is completely wrong, I dont seem to get this on a live running chart.

Please see the attached image to see what I mean:

 

Thank you in advance

 

Antony 

 
tonyjms2005:

Hi

I seem to be running into this backtesting issue time and time again, and was wondering if there is anything I can do, or perhaps is there anything I am doing wrong.

Basicall when calling this code on the tester its returns I value of over 1000:

Have I done something wrong there because the returned value is completely wrong, I dont seem to get this on a live running chart.

Do you have correct W1 data for that symbol ?  open a W1 chart and check . . . 
 

Hi

Thanks for the reply.

I have just tried deleting importing the history covering all timeframes including M1 but the issue is still there. I tired using:

iBarShift(Symbol(),Period(),iTime(Symbol(),PERIOD_D1,2),false);

 But that also returns the wrong value.

 

Thanks

 

Antony 

 
Under the tester you only have 1000 bars of history (or less.) so the iBarShift is pointing to the earliest bar.
 
tonyjms2005:

Hi

Thanks for the reply.

I have just tried deleting importing the history covering all timeframes including M1 but the issue is still there. I tired using:

 But that also returns the wrong value.

I just tried your original code on my GBPUSD data from April 2012 and I get the correct result to within 1 bar,  perhaps you should show your code or at least code something else that you can share that reproduces the problem.

I used this line of code in my test EA . . .

   Comment("Week start bar number on timeframe ", Period(), " is # ",  iBarShift(Symbol(),Period(),iTime(Symbol(),PERIOD_W1,0),false) );

 and get this . . .

Week start bar no. 

 

Hi again, I tried an EA with just this:

  

//+------------------------------------------------------------------+
//|       Start                                                      |
//+------------------------------------------------------------------+
void start(){Print("Week start bar = ",iBarShift(Symbol(),Period(),iTime(Symbol(),PERIOD_W1,0),false));

return;
}

//+------------------------------------------------------------------+ 
//END

It still returns this error, I have tried, reinstalling the terminal, trying a different terminal, repopulating the history data with new data.

Any idea?

Thanks

Antony 

 

Also forgot to add, I tried this also:

 

Print("itime = " ,iTime(Symbol(),PERIOD_W1,0));

and it returns 0  

 
tonyjms2005:

Hi again, I tried an EA with just this:

  It still returns this error, I have tried, reinstalling the terminal, trying a different terminal, repopulating the history data with new data.

Any idea?

How are you repopulating the data ?  all my data is derived from tick data,  the tick data is used to create the M1, M5, M30, etc data so I know I have no mismatches in my data.  

You might also try letting the Strategy Tester run for a full week beyond the start point and then see what result it gives,  that might tell you something. 

 
Testing Features and Limits in MetaTrader 4 - MQL4 Articles states
Weekly, monthly, and irregular timeframes are not tested
It also states "Zero bar of another timeframe for the same symbol under test is modeled approximately" which is no longer true.