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.
| Identical updates k | EMA A | EMA B | Absolute difference |
|---|---|---|---|
| 0 | 100.000000 | 90.000000 | 10.000000 |
| 1 | 100.000000 | 92.000000 | 8.000000 |
| 5 | 100.000000 | 96.723200 | 3.276800 |
| 10 | 100.000000 | 98.926258 | 1.073742 |
| 20 | 100.000000 | 99.884708 | 0.115292 |
| 21 | 100.000000 | 99.907766 | 0.092234 |
Open full-size diagram- After 1 update: 8 price units
- After 5 updates: 3.277 price units
- After 10 updates: 1.074 price units
- After 20 updates: 0.115 price units
- After 21 updates: 0.092 price units
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.