Does it make sense to call BarsCalculated form a custom Indicator?

To add comments, please log in or register
Laszlo Tormasi
4826
Laszlo Tormasi  

Hello,

I have an Indicator which calls an another CPU heavy custom indicator (on 7 different currencies).

So, in the Init function I create the 7 handles and within OnCalculate I use CopyBuffer to get the data. 

Sometimes this indicator starts normally but sometimes it seems the buffers are not ready when the first OnCalculate call is made.  

I can use BarsCalculated like: 

//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
for(int i=0;i<7;i++)
   {
   if(BarsCalculated(SYM[i].GetHandle(i))<10)
      {
      return 0;
      }
   }

But on the weekend there won't be second OnCalculate call. How can I trigger the OnCalculate on the weekend once the Buffers are ready? 


ps: I am not 100% sure that my assumption is correct and by design the OnCalculate gets called only when all data is ready. This would mean that I have a different issue with my indicator. 

ps.ps. I forgot to mention. This indicator works properly in MT4 environment. In mt5 sometimes it does not load right. 

Alain Verleyen
37698
Alain Verleyen  
ChartSetSymbolPeriod(0,NULL,0);
To add comments, please log in or register