How to get the range of indices of lower time frame candles that are included in a specific higher time frame candle?

 
As the question describes, let us assume that we have an index corresponding to a higher time frame candle. Now, I am interested in getting the range of indices of all candles which are included in that specific candle. To make things clear, let me give an example. Let us say that I have the index of an H4 candle, which is 23. Then I want to get the range of indices of all M15 candles which are inside that 23rd H4 candle. What would be an efficient way to do this?
 
Hosein Rahnama: Let us say that I have the index of an H4 candle, which is 23. Then I want to get the range of indices of all M15 candles which are inside that 23rd H4 candle. What would be an efficient way to do this?

When in doubt, think.

Not tested, not compiled, just typed.

int      iH4=23;
datetime tH4Beg    = iTime(_Symbol, PERIOD_H4, iH4), 
         tH4Last   = tH4Beg + PeriodSeconds(PERIOD_H4) - 1;
int      iM15Start = iBarShift(_Symbol, PERIOD_M15, tH4Beg),
         iM15Last  = iBarShift(_Symbol, PERIOD_M15, tH4Last);

Not tested, not compiled, just typed.


On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)

Reason: