how to check if current bar is 10 bars away from previous bar?

 

how to check if current bar is less than 10 bars away from previous bar?

Datetime Previous_bar_Time = iTime(_Symbol,_Period,0);
if (Time[0] < Previous_Bar_Time + Time[10]) { //do something }

I think the formula above is wrong, may I know what is the correct formula?

 
Documentation on MQL5: Timeseries and Indicators Access / iBarShift
Documentation on MQL5: Timeseries and Indicators Access / iBarShift
  • www.mql5.com
//| Script program start function                                    | //
 

ok thanks. It works.

Datetime Previous_bar_Time = iTime(_Symbol,_Period,0);
int Shift = iBarShift(NULL,0,SellFirstBeyondTime);
if (Shift < 11 ) { //then do something }
 
   static datetime Previous_bar_Time = iTime(_Symbol,PERIOD_CURRENT,0);
   if(iBarShift(_Symbol,PERIOD_CURRENT,Previous_bar_Time,true)<11)
   {
     //do something
   }
 
Mehrdad Jeddi:

Thanks