Mohammadal Alizadehmadani: The result differs from the Moving averag indicator.
LineBuffer[i] = close[i];
The buffer is as-series. You didn't set your array likewise.
To define the indexing direction in the time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[] arrays, call the ArrayGetAsSeries() function. In order not to depend on defaults, call the ArraySetAsSeries() function for the arrays to work with.
OnCalculate - Event Handling - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
OnCalculate - Event Handling - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
I tried to write the equivalent for the iMAOnArray function in MetaTrader 4 using MovingAverages.mqh in MetaTrader 5. The problem is obvious in the attached photos. The result differs from the Moving averag indicator. It is also not calculated for period 1.
code: