A way to set the Index Buffer to Regions without using &time[]

 

How do I get a region, lets say daily TF to display the same value for my index buffer, without having to use time[] array. I used iTime() to get the values of the various time to calculate for, but the index buffer is having different values for each candle and not the time frame regions.

Thanks

 

iBarShift()  will match bar time values.


Here indexes matching bar time. 

example:

      for(x=0; x<limit; x++)
      {
         s2[x] = iStdDev(NULL, TimeFrame2, ma_period, ma_shift, ma_method, applied_price,  iBarShift(NULL, TimeFrame2, Time[x], false));
      }
   

https://docs.mql4.com/series/ibarshift

iBarShift - Timeseries and Indicators Access - MQL4 Reference
iBarShift - Timeseries and Indicators Access - MQL4 Reference
  • docs.mql4.com
iBarShift - Timeseries and Indicators Access - MQL4 Reference
 
maximo #:

iBarShift()  will match bar time values.


Here indexes matching bar time. 

example:

      for(x=0; x<limit; x++)
      {
         s2[x] = iStdDev(NULL, TimeFrame2, ma_period, ma_shift, ma_method, applied_price,  iBarShift(NULL, TimeFrame2, Time[x], false));
      }
   

https://docs.mql4.com/series/ibarshift

Thanks 
 
What I came to understand with regards to the above is, for the buffer to have the same value, it has to be stored for the entire region
time1 = iTime(_Symbol, PERIOD_D1, 0);                   // Time 1 (Start)
time2 = iTime(_Symbol, PERIOD_D1, 1);                   // Time 2 (End)

//--- For the above region to have the same value in the buffer, get the bars corresponding with the using 
//iBarShift(), then loop through it to store through the bars, stores the values

int start, end;
start = iBarShift(_Symbol, 0, time1);
end   = iBarShift(_Symbol, 0, time2);
 while(start < end)
  {
     buffer[start] = value to be stored;
     start++;
  }

//--- If you noticed, I used "0" and not a particular period, because we want the region in whatever 
timeframe we are looking at.