7 days Pro+ free · no cardStart my free trial

Indicator mechanics: reconstruct what the chart calculates · 5 / 5

Why two EMAs disagree: reconcile warm-up history and seeds

Matching the latest candles and lookback length is not enough to reproduce a recursive indicator. Its current value still carries information from the state with which it started.

Athenum7 minUpdated:

Distinguish formula readiness from numerical agreement

An exponential average follows Eₜ = α × Pₜ + (1 − α) × Eₜ₋₁. To replay it you need α, the price source, ordered observations and an initial state. Implementations may seed with a simple average of an initial window or use another declared convention. Loading more historical observations can therefore change the value on the same latest candle.

A library’s ready flag answers that library’s initialization requirement. It does not prove two histories agree within a tolerance you care about. First compare instrument, venue, adjustments, candle timestamps, input field and missing-bar handling. Only after aligning those inputs should you attribute a difference to the seed.

Calculate how much starting-state difference remains

For two EMAs with the same fixed α and identical subsequent inputs, subtract their recurrences. The input cancels, leaving Dₜ = (1 − α) × Dₜ₋₁. After k updates, Dₖ = D₀ × (1 − α)^k. This identity measures the remaining seed difference, not either series’ distance from a true price or an optimal forecast.

Choose a comparison tolerance before looking at a trading outcome. A tolerance in absolute price units has different implications across instruments; a relative or tick-based tolerance also needs a declared reference. If inputs later diverge, the seed-only equation no longer accounts for the entire discrepancy. Rounding each intermediate update can introduce another difference.

A nine-period EMA needs 21 identical updates for this chosen tolerance

Use α = 2 / (9 + 1) = 0.2. Two valid prior histories leave current EMA states A = 100 and B = 90. From that point, both receive the same hypothetical close of 100 on every update. A stays at 100; B follows 100 − 10 × 0.8^k. These are deliberately assigned starting states, not an assertion that a particular platform seeds this way.

After 20 updates the difference is approximately 0.115292, which exceeds a predeclared 0.1-price-unit tolerance. After 21 it is approximately 0.092234, so 21 is the first sufficient integer count for this example. A nine-period name does not mean all earlier influence disappears after nine bars. More history is a reproducibility choice, not evidence of a better trading edge.

Original seed-convergence example; calculations retain precision before rounding
Identical updates kEMA AEMA BAbsolute difference
0100.00000090.00000010.000000
1100.00000092.0000008.000000
5100.00000096.7232003.276800
10100.00000098.9262581.073742
20100.00000099.8847080.115292
21100.00000099.9077660.092234
Remaining absolute seed difference after identical inputs; the 0.1 tolerance is first met at update 21.Open full-size diagram
  1. After 1 update: 8 price units
  2. After 5 updates: 3.277 price units
  3. After 10 updates: 1.074 price units
  4. After 20 updates: 0.115 price units
  5. After 21 updates: 0.092 price units
Remaining absolute seed difference after identical inputs; the 0.1 tolerance is first met at update 21.

More historical bars cannot fix a different price series

One chart using mark-price closes and another using last-trade closes need not converge to each other merely because both load a long history. The cancellation argument requires identical inputs at every compared update. Check that prerequisite before endlessly increasing a warm-up window.

Before acting

  • Match instrument, price field and candle clock.
  • Record seed convention and earliest observation.
  • Match α and intermediate precision.
  • Separate readiness from a declared numerical tolerance.
  • Investigate input divergence when the seed-only bound fails.

Check your understanding

The starting-state difference is again 10, but α is 0.5 and the tolerance is 0.25. How many identical updates are needed?

Show the explained answer

The remaining difference is 10 × 0.5^k. After five updates it is 0.3125, above 0.25; after six it is 0.15625, below 0.25. Six is therefore the first sufficient count, provided both sequences receive identical inputs and retain the stated arithmetic.

Sources and further reading

Continue with Athenum