When CopyBuffer returns -1 and market is closed at end of day or weekend

 

I have an indicator that uses iCustom and CopyBuffer to load the data from another indicator (same symbol, different timeframe). CopyBuffer will usually return -1 on the first call of OnCalculate(), meaning data is not yet available. This is not usually a problem as I return 0 and on the next call of OnCalculate() the call to CopyBuffer will fill my array.

But, when the market is closed the next call to OnCalculate() could be many hours away and my indicator will have nothing to calculate or plot. What would be the recommended way to handle this?

I apologize if this has been answered before or is covered in the documentation - I have looked.

 
robnorthen:

I have an indicator that uses iCustom and CopyBuffer to load the data from another indicator (same symbol, different timeframe). CopyBuffer will usually return -1 on the first call of OnCalculate(), meaning data is not yet available. This is not usually a problem as I return 0 and on the next call of OnCalculate() the call to CopyBuffer will fill my array.

But, when the market is closed the next call to OnCalculate() could be many hours away and my indicator will have nothing to calculate or plot. What would be the recommended way to handle this?

I apologize if this has been answered before or is covered in the documentation - I have looked.

Use ChartSetSymbolPeriod(0,NULL,0) to simulate a chart refresh.
 
You should just return rates_total-1 instead of rates_total. I think this will suffice to trigger another call to OnCalculate.
 
lippmaje:
You should just return rates_total-1 instead of rates_total. I think this will suffice to trigger another call to OnCalculate.
Nope. No ticks no trigger, except at the start, the returned value doesn't matter.
 
Alain Verleyen:
Use ChartSetSymbolPeriod(0,NULL,0) to simulate a chart refresh.

Thank you Alain, I'll try that.

Reason: