Moving AveragesPine Script v6

ta.alma()

Arnaud Legoux Moving Average

Computes the Arnaud Legoux Moving Average (ALMA), a Gaussian-kernel weighted average over length bars. Parameters offset and sigma let you tune responsiveness versus smoothness; optional floor controls window flooring behavior.

Syntax

Syntax
ta.alma(series, length, offset, sigma, floor) → series float

Arguments

ParameterTypeDescription
seriesseries int/floatSeries of values to process.
lengthseries intWindow size for the Gaussian kernel.
offsetsimple int/floatControls tradeoff between smoothness and responsiveness.
sigmasimple int/floatChanges smoothness of the Gaussian weights.
floorsimple boolOptional; default false.

Returns

Arnaud Legoux Moving Average.

Remarks

na values in the source series are included in calculations and will produce an na result.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.alma", overlay=true)
plot(ta.alma(close, 9, 0.85, 6))

// same on pine, but much less efficient
pine_alma(series, windowsize, offset, sigma) =>
    m = offset * (windowsize - 1)
    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))

Trading Applications

Use Gaussian distribution weighting for adaptive smoothing

Fine-tune responsiveness vs smoothness with offset parameter

Reduce lag while minimizing false signals

Apply in algorithmic trading systems requiring precise MA tuning

Frequently Asked Questions

Generate ta.alma() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.alma() and other built-in functions instantly.