What is the relationship between PLOT_SHIFT, CopyBuffer and indicator handle

 

I am working on an EA that for the last candle uses, say the value 5 candles ago.

To visualize this, I use PLOT_SHIFT with a value of 5, so I can see the value 5 candles ago in the latest candle. Graphically looks fine.

The problem I am having is that this ruins the data I get in the CopyBuffer, like if they were offset by a random number. Is the handle of the indicator modified when using PLOT_SHIFT ?

In other words, when I use PLOT_SHIFT in MQL5, i move the graphic display, as well as the handle of the indicator?

 
Camilo Mora:

I am working on an EA that for the last candle uses, say the value 5 candles ago.

To visualize this, I use PLOT_SHIFT with a value of 5, so I can see the value 5 candles ago in the latest candle. Graphically looks fine.

The problem I am having is that this ruins the data I get in the CopyBuffer, like if they were offset by a random number. Is the handle of the indicator modified when using PLOT_SHIFT ?

In other words, when I use PLOT_SHIFT in MQL5, i move the graphic display, as well as the handle of the indicator?

When you use plot shift you are shifting the complete buffer by a certain value. So when using copy buffer you need take that shift value into account.