Skip to content
Algo Trade Analytics Docs

ta.alma() - Pine Script Function

Arnaud Legoux Moving Average. It uses Gaussian distribution as weights for moving average.

ta.alma(series, length, offset, sigma, floor) → series float
NameTypeDescription
seriesseries int/floatSeries of values to process.

Arnaud Legoux Moving Average.

  • na values in the source series are included in calculations and will produce an na result.
//@version=6
indicator("ta.alma", overlay=true)
plot(ta.alma(close, 9, 0.85, 6))// same on pine, but much less efficientpine_alma(series, windowsize, offset, sigma) => m = offset * (windowsize - 1) //m = math.floor(offset * (windowsize - 1)) // Used as m when math.floor=true s = windowsize / sigma norm = 0.0 sum = 0.0
for i = 0 to windowsize - 1 weight =
math.exp(-1 * math.pow(i - m, 2) / (2 * math.pow(s, 2)))
norm := norm + weight sum := sum + series[windowsize - i - 1] * weight sum / norm
plot(pine_alma(close, 9, 0.85, 6))