EMA
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: EMA = SMA of first period bars.
Notes
- 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
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 30 | 1–100000 | Number of bars in the average; sets smoothing k = 2/(period+1) |
Properties
Numerical Stability: Initial Unstable Period
| Display Flags |
|---|
| ✅ Overlap Input i |
| ☐ Independent Y-Axis |
| ☐ Candlestick |
Implementation
TA-Lib Definition: ema.c · ema.yaml
| Native | File |
|---|---|
| C | ta_EMA.c |
| Rust | ema.rs |
| Java | Core_EMA.java |
TA-Lib is also available for Python, R and more using a wrapper.
Aliases
Exponential Moving Average, Exponentially Weighted Moving Average, EWMA