Skip to content

EMA

Summary

Exponential moving average that weights recent prices more heavily via a recursive smoothing factor. A core building block seeding or composing many other indicators. Reacts faster than SMA; price above/below EMA suggests up/down trend.

Formula

k = 2 / (period + 1); EMA_t = (price_t - EMA_{t-1}) * k + EMA_{t-1}. Seed (DEFAULT): EMA = SMA of first period bars.

Notes

  • In Metastock compatibility mode the average is seeded with the first price value and the recursion starts at the second bar, rather than the default of seeding with a simple average of the first period bars.
  • A period of 1 performs no smoothing: the output is a copy of the input. Allowed since 0.6.5 (issues #48/#59).

Inputs

  • inReal — price/data series to smooth

Outputs

  • outReal — the exponential moving average

Parameters

  • optInTimePeriod — number of bars in the average; sets smoothing k = 2/(period+1)

Implementation

TA-Lib Definition: ema.c · ema.yaml

Native File
C ta_EMA.c
Rust ema.rs
Java Core.java

TA-Lib is also available for Python, R and more using a wrapper.

Aliases

Exponential Moving Average, Exponentially Weighted Moving Average, EWMA

See Also

SMA · DEMA · TEMA · MA · MACD · T3