Skip to content
All library documents

EMA Initialization and Differences Across Implementations

Article FMZ forum · Author: 懒猪

Summary

This brief post asks why a long-period exponential moving average (EMA) calculated in TradingView differs from results produced by common Python libraries. It presents TradingView’s recurrence: use a simple moving average to seed the series, then update each value with a smoothing factor of two divided by the period plus one. The questioner notes that Python’s exponentially weighted mean and TA-Lib EMA agree with TradingView for shorter periods in their tests, but diverge at longer periods.

The useful point is that matching an EMA requires matching its initialization and handling of early observations, not just its smoothing factor. The post does not provide a tested Python translation, a worked numerical comparison, or a definitive explanation for the observed differences. It is therefore a focused implementation question rather than a complete indicator tutorial; users would need to verify seed rules, available history, and missing-value behavior against their own data and platform settings.

Key ideas

  • An EMA implementation depends on both its recursive smoothing rule and its initial value.
  • The TradingView example seeds the series with a simple moving average before applying the recursive update.
  • The author reports that two Python EMA implementations diverged from TradingView at longer periods in their tests.
  • The post raises an implementation question but does not supply a verified translation or identify the precise source of the mismatch.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.