EMA

Calculates the Exponential Moving Average indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
applyToSeries<Number>--
periodNumber14-

Returns: Series<Number>

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

1 function EMA(applyTo, period = 14):
2 alpha = 2 / (period + 1)
3 series EMA:
4 once: SMA(applyTo, period)
5 then: alpha * applyTo + (1 - alpha) * EMA[1]