ALMA

Calculates the Arnaud Legoux Moving Average indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
applyToSeries<Number>
close
-
periodNumber14-
offsetNumber0.85-
sigmaNumber3-

Returns: Series<Number>

ALMA is a built-in function - you can use it directly. Below is an example implementation:

12345678910111213
function ALMA(applyTo = close, period = 14, offset = 0.85, sigma = 3):
m = Math.Floor(offset * (period - 1))
s = period / sigma
sum = 0
sum2 = 0

for i from 0 to period - 1
w = ((i + 1) - m) ** 2
exp = Math.E ** (-w / 2)
sum = sum + exp
sum2 = sum2 + applyTo[i] * exp

sum2 / sum