Exponential moving average

emamoving_averagesForge API 1

Average that weights recent values more, each step closing part of the gap to the price.

Inputs

NameTypeDefaultRange
sourcesourceclose
periodint141 to 5000

Outputs

NameTypeRequiredDescription
emavalueOptionalcolor theme.accent, style line, width 1
Warm-up
period - 1 bars (13 at the defaults)
Repaints
No
Parity
MetaTrader 5, within 1e-12

Formula

k = 2 / (period + 1)

EMA[i] = x[i] * k + EMA[i-1] * (1 - k), starting from the first price.

The first period - 1 values are left empty. After a gap the average starts again.