Multi Time Frame Backtest Analysis/Coding with MQL4 - page 2

 
Douglas Tybel:


then, this will backtest using data period_m5 and period_m1.


Do you understand?

Are you saying that you save a GV before backtesting so that you can then use the GV in the test?

A single random value?

That is absolute nonsense!

You can get the value of an indicator in different time-frames within the backtest, no need for GVs.

Why are you trying to solve a problem that doesn't exist??

 

this code below doesn't works in the backtest Metratader 4 within period M1, try:

double o=iOpen(NULL,PERIOD_M5,i);
double h=iHigh(NULL,PERIOD_M1,i);

if (o > h){
  //code

}

it can't get value of period_m5 with backtest period_m1.

the single way I did it to work it was Just putting a GV in the expert sending the value to indicator that is in backtesting

 
Douglas Tybel:

this code below doesn't works in the backtest Metratader 4 within period M1, try:

it can't get value of period_m5 with backtest period_m1.

   int i=1;
   double o=iOpen(NULL,PERIOD_M5,i);
   double h=iHigh(NULL,PERIOD_M1,i);
   Print("o=",DoubleToStr(o,Digits)," h=",DoubleToStr(h,Digits));
   if (o > h)
      Print("It is");
   else
      Print("It isn't");
      

Works perfectly on any time-frame

2019.12.20 11:14:22.631 2019.12.19 00:05:00  SMA_Price_action_strategy_v2.0 GBPUSD,M1: o=1.30817 h=1.30790

2019.12.20 11:14:22.631 2019.12.19 00:05:00  SMA_Price_action_strategy_v2.0 GBPUSD,M1: It is

 

thank you for help me

I saw my error

when I use variable it works fine, directly doens't work. Now I got it!

 double o=iOpen(NULL,PERIOD_M5,i);
   double h=iHigh(NULL,PERIOD_M1,i);
	

   Print("o=",DoubleToStr(iOpen(NULL,PERIOD_M5,i),Digits)," h=",DoubleToStr(h,Digits));

   if (o > h)
      Print("It is");
   else
      Print("It isn't");