Indicator lines get moved 128 candles?

 

I have an indicator that shows how many logs/shorts there should be open. This indicator is also used by an EA to open and close positions. This same system works with several strategies for a year now.

As I have been testing a new strategy on a demo, a really weird thing happened. Every now and then, the whole indicator shifts (and then it also shifts back to it's original place after a while, say half an hour). It's by exactly 128 candles.

I know there's a possibility of a coding error, but well it's coded so that it only calculates data from the last known candle, i.e. "does not repaint", it only changes candle[0]. And as it shifts, the values on all buffers become EMPTY_VALUE.


Any clue as to why this could happen?

The red lines in the indicator window were hand-drawn when the indicator was refreshed (and was still correct). The green lines are the current state of the indicator, that is, after this weird shift happened.


 
Papler:
Any clue as to why this could happen?
No psychics here, post the code