Backtesting - Difference in open information

 

Hi all

 I'm a very "new newbie" in MQL5 (I've experiences in other progr. lang. but not in MQL5). I trade for more than two years and now is time to start with developing EA to make trading (hopefully) easyier and less risky.

 To my challange...

 I need the OPEN information of the last and previous Bar. I do that with the following statements (two different approaches):

CopyOpen(Symbol(), PERIOD_CURRENT, 0,100,la_open);
CopyRates(Symbol(), PERIOD_CURRENT, 0,100, la_rates);

if (lv_res == true)
{
   Print ("O: ", la_open[0], " ", la_open[1]);
   Print ("R: ", la_rates[0].open, " ", la_rates[1].open);

}

 If I run a backtest I get differences between the chart information and the journal. See the following screenshot (2012.09.03 - 01:00):

 

 

What's wrong here?

 

 I appreciate any help.

 thanks, TA 

 
fx_ta:

Hi all

 I'm a very "new newbie" in MQL5 (I've experiences in other progr. lang. but not in MQL5). I trade for more than two years and now is time to start with developing EA to make trading (hopefully) easyier and less risky.

 To my challange...

 I need the OPEN information of the last and previous Bar. I do that with the following statements (two different approaches):

 If I run a backtest I get differences between the chart information and the journal. See the following screenshot (2012.09.03 - 01:00):

What's wrong here?

 I appreciate any help.

 thanks, TA 

Hi fx_ta,

Nothing wrong with your codes except this

if (lv_res == true)
{
   Print ("O: ", la_open[98], " ", la_open[99]);
   Print ("R: ", la_rates[98].open, " ", la_rates[99].open);

}

You may want to try that. Try also CopyTime() to see if selected time is correct.

Here CopyRates()CopyOpen() , and CopyTime() - click that - look at the picture shown there - just the picture, that's how to 'read' the copied data.

 

 

Add to OnInit() this code :

   ArraySetAsSeries(la_open,true);
   ArraySetAsSeries(la_rates,true);

 And leave the old indexing [0],[1].

 

Hi both,

Thanks very much. I've solved the problem with your input. 

 Best Regards,

 FX_TA