ta.alma
Smooth a series with a Gaussian weighted average that balances lag and smoothness.
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.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
source | Series | number | - | - | The series to read. |
length | Constant | number | 9 | 1 to 10000 | Window in observed bars. |
offset | Constant | number | 0.85 | 0 to 1 | Where the Gaussian sits in the window: 1 is the newest bar, 0 the oldest. |
sigma | Constant | number | 6 | 0.001 to 100 | How sharp the Gaussian is: larger is narrower and less smooth. |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
lengthbars. Names in the warm-up are this operator’s parameters.- Missing values
- Returns na until
lengthconsecutive non-na observations are in the window. An na resets the accumulation.
Example
ta.alma(close, 9, 0.85, 6)plot(ta.alma(close, 9, 0.85, 6), "Gaussian 9")