Sidechair

ta.alma()

Browse the reference

Returns the Arnaud Legoux moving average, a Gaussian-weighted average whose peak can be shifted toward recent or older bars.

Try it in the editor

ta.alma weights each bar in the window with a bell curve centred at offset * (length - 1) bars from the oldest, with width length / sigma. The weights are normalised so they sum to one.

A high offset such as 0.85 keeps the curve close to price; a low offset adds smoothing and lag. A larger sigma narrows the bell and makes the average behave like a short one inside a long window.

Syntax

Pine Script
ta.alma(series: series int/float, length: series int, offset: simple int/float, sigma: simple int/float, floor: simple bool) -> series float

Arguments

NameTypeDefaultDescription
seriesseries int/floatrequiredSeries of values to average.
lengthseries intrequiredNumber of bars in the window. A whole number of 1 or more.
offsetsimple int/float0.85Position of the bell's peak from 0 (oldest bar) to 1 (newest bar).
sigmasimple int/float6Width control: the bell's standard deviation is length / sigma. Larger values give a narrower, more local weighting.
floorsimple boolfalseWhen true, the peak position offset * (length - 1) is rounded down to a whole bar.

Returns

series float: the Gaussian-weighted average, or na on the first length - 1 bars.

Remarks

  • The three tuning arguments are optional, so ta.alma(close, 9) works with the usual 0.85 and 6.

Example

Pine ScriptALMA with default shapeOpen in editor
//@version=6
indicator("ALMA", overlay = true)
plot(ta.alma(close, 9, 0.85, 6), "ALMA", color = color.blue, linewidth = 2)
plot(ta.sma(close, 9), "SMA", color = color.gray)

See also

Runs on Sidechair