General conditions on the indexes of an indicator (e.g. MA) with a minimum required bars present before the calculation can be performed - page 2

 
LRDPRDX # :


That's all I need. From this definition this code should be used (I think) :

Yes everything is correct. If you need a bar [i-1], you need to synchronize the origin:

if(rates_total<2 )
      return(0);
//---
int limit=prev_calculated-1;
if(limit<1)
{
  HighestBuffer[0]=0.0;
  limit=1;
}
//--- main loop
for( int i=limit; i<rates_total; i++)
   HighestBuffer[i]=Func(price[i],price[i-1]);
//--- return value of prev_calculated for next call
return(rates_total);
 
Vladimir Karputov #:

Yes everything is correct. If you need a bar [i-1], you need to synchronize the origin:

Good ! Finally we're clear :)

Thank you for the conversation.