Call OnInit() when a new candle is on the chart

To add comments, please log in or register
Dan
103
Dan  

Hey everybody,

my indicator draws lines on the chart and on every new day I want the re-initialize the indicator again.

In the OnCalculate() function I will put the following:

OnCalculate(const int rates_total,      // size of input time series
                 const int prev_calculated,  // bars handled in previous call
                 const datetime& time[],     // Time
                 const double& open[],       // Open
                 const double& high[],       // High
                 const double& low[],        // Low
                 const double& close[],      // Close
                 const long& tick_volume[],  // Tick Volume
                 const long& volume[],       // Real Volume
                 const int &spread[]) // Spread)
{
static datetime candletime;

if(iTime(NULL,PERIOD_D1,0)!=candletime)
 {
  OnInit();
  candletime=iTime(NULL,PERIOD_D1,0);
 }

return(rates_total);
}


unfortunately this is not working. What is wrong with this?

Thanks for help!

To add comments, please log in or register