ta.alma() - Pine Script Function
ta.alma()
Section titled “ta.alma()”Overview
Section titled “Overview”Arnaud Legoux Moving Average. It uses Gaussian distribution as weights for moving average.
Syntax
Section titled “Syntax”ta.alma(series, length, offset, sigma, floor) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| series | series int/float | Series of values to process. |
Returns
Section titled “Returns”Arnaud Legoux Moving Average.
Remarks
Section titled “Remarks”- na values in the source series are included in calculations and will produce an na result.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("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.0for 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 / normplot(pine_alma(close, 9, 0.85, 6))