Skip to content

Superseded (2026-05-25) — this operator is a Layer-1 transform, not a Layer-0 atomic input. Merged into compute_ema_v1. Kept for history.

What (One-liner)

EMA Exponential Moving Average (α = 2/(n+1) convention, adjust=False recursive).

How to use

python
from services.algo.technical import compute_ema
compute_ema(prices, period=12)  # MACD fast line
compute_ema(prices, period=26)  # MACD slow line

Core formulas

α = 2 / (period + 1)
EMA_0 = P_0
EMA_t = α × P_t + (1-α) × EMA_{t-1}

# pandas equivalent
prices.ewm(span=period, adjust=False).mean()

Assumptions & applicability

Assumptions: TradingView / MT4 convention α = 2/(n+1) + recursive (adjust=False) + first-value init.

Applicable: MACD, Bollinger middle, momentum strategies.

Not Applicable: Wilder α=1/n (that is RSI), short series.

Known limitations

  1. α hardcoded 2/(n+1)
  2. adjust=False recursive (early periods biased)
  3. Equidistant assumption

References

Murphy (1999) + Roberts (1959) EWM statistical origin.

Golden Test

tests/golden/fixtures/tier1/compute_ema/, 1e-12, 2026-04-20 passing.

Changelog

  • 1.0.0 (2026-04-20) — First Active

Verifiable intelligence for the decisions that demand scrutiny.