Docs

ta.alma

Smooth a series with a Gaussian weighted average that balances lag and smoothness.

itm
ta.alma(source, length, offset, sigma)

Arnaud Legoux moving average: a Gaussian-weighted window average. The weight of the observation i bars from the oldest end is exp(-(i - m)^2 / (2*s^2)) with m = offset*(length - 1) and s = length/sigma, normalised by their sum. The offset is not floored, so a fractional m shifts the peak between bars.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--The series to read.
lengthConstantnumber91 to 10000Window in observed bars.
offsetConstantnumber0.850 to 1Where the Gaussian sits in the window: 1 is the newest bar, 0 the oldest.
sigmaConstantnumber60.001 to 100How sharp the Gaussian is: larger is narrower and less smooth.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
length bars. Names in the warm-up are this operator’s parameters.
Missing values
Returns na until length consecutive non-na observations are in the window. An na resets the accumulation.

Example

itm
ta.alma(close, 9, 0.85, 6)
itm
plot(ta.alma(close, 9, 0.85, 6), "Gaussian 9")