VPS : Failed to read the ATR buffer

 

Fot those that had this issue, and there are many around, this happens only on day one of renting the VPS, as it magically disappeared for me o both my VPS at ... 00:00 next day.


This is so weird we cannt control the connectors and cache when synchronizing from MT5.

 
Emmanuel PIERRE:

Fot those that had this issue, and there are many around, this happens only on day one of renting the VPS, as it magically disappeared for me o both my VPS at ... 00:00 next day.


This is so weird we cannt control the connectors and cache when synchronizing from MT5.

you need to make sure the indicator is "ready" before trying to retrieve the data. indicators aren't always ready when you start the backtest
 

On a fresh VPS the symbol history is often still syncing, so the ATR handle exists but has no calculated data yet and CopyBuffer returns -1. Check BarsCalculated first and just skip that tick if it's not ready:

if(BarsCalculated(atrHandle) <= 0) return;   // not ready yet, try next tick
double atr[];
if(CopyBuffer(atrHandle, 0, 0, 1, atr) != 1) return;

Once the history finishes downloading it works on its own, which would explain why it went away by itself the next day.

 

hi...@Emmanuel PIERRE

I’ve seen similar behaviour with indicator buffers on VPS, but I wouldn’t rely on the issue disappearing at 00:00 as the solution.
It can happen when the terminal has started but the required history/indicator data is not fully synchronized or calculated yet.

For an ATR handle, I’d check both:

if(!SeriesInfoInteger(_Symbol, PERIOD_M15, SERIES_SYNCHRONIZED)) return; if(BarsCalculated(atr_handle) <= 0) return;

and always check the return value of CopyBuffer() . If the data isn't ready, retry later rather than treating it as a zero/invalid ATR.

This is especially useful on VPS startup, because the terminal may be ready before all requested series and indicator buffers are ready. The fact that it starts working later suggests a synchronization/initialization issue, although the exact cause would need the journal/error code to confirm it.