I need help to get the correct indicator values for current and preceding candlesticks

 
I am learning how to code in mql5, I am trying to make an EA but can't be able to get the correct indicator values for each candlestick, I hope some experienced programmer can help.
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2025.04.05
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Files:
Live_EA_1.mq5  8 kb
 

You may study and test the sample code available in documentation.

https://www.mql5.com/en/docs/series/copybuffer

Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
Gets data of a specified buffer of a certain indicator in the necessary quantity. Counting of elements of copied data (indicator buffer with the...
 


set the buffers to series if you want to get price values of multiple candlesticks from the current going backwards