Find clicked MqlRate - page 2

UnknownInnocent
301
UnknownInnocent  
UnknownInnocent #:

Okay thank you for the hint. Now I just tried to calculate the number of missing candles and subtract it in numberOfRates:

The idea seems to be right but I do have problems with the "fine-tuning" of numberOfSkippedRates" (where time is the datetime of the bar that I want to count the skipped candles for). Generally it works fine but from time to time there is a bar where it does not work. Any Idea how to fix it?

I changed my clickedRate to

MqlRates getClickedRate(const ENUM_TIMEFRAMES timeframe, const datetime &time) {
   MqlRates rates[];
   int index = iBarShift(Symbol(), timeframe, time, true);
   CopyRates(Symbol(), timeframe, (index >= 0 ? index - 1 : 0), 1, rates);
   if(index < 0) {
      SetUserError(4001);
   }
   
   return rates[0];
}

Now it works fine