Forums ProRealTime English forum ProBuilder support Indicator displacement to left Reply To: Indicator displacement to left

#242055
JS

Hello

To “shift” a moving average, you can use the following code:

Avg = Average[20](Close)

AvgShift = Average[20](Close[5])

In this example, the “shift” is determined by the number 5, meaning the calculation looks back 5 candles into the past. The Average effectively starts 5 candles earlier.

Visually, on the chart, it appears as though the average is shifted to the right because the values from 5 candles ago are being displayed in the current period…

Technically, the moving average itself is not shifted. Instead, it is calculated using older data (from 5 candles ago). This creates the appearance of a rightward shift while simply using a different dataset for the calculation…