In this article
After this article, you can
- Separate the latest price change from the rolling-average change.
- Calculate the effect of replacing an old SMA observation.
Terms at hand: Exponential Moving Average (EMA) · Simple Moving Average (SMA) · Backtesting · Commission · Demo account · Stop loss
EMA weights recent observations more heavily; SMA weights each observation in its window equally. Neither formula alone establishes superior trading results.
Does a rising average mean the latest price rose?
Four hypothetical closes are 90, 100, 110 and 105. Compare average updates from the third to fourth candle.
Scroll sideways to see the full diagram
Two formulas, two personalities
SMA(N) is the sum of N selected prices divided by N. Each carries weight 1/N: SMA20 assigns 5% to each of twenty bars on one stated interval. A new observation replaces the oldest, so the update is (new price − dropped price)/N. Its sign need not match the change from the immediately preceding close.
Standard EMA uses α = 2/(N + 1) and EMA(t) = α × C(t) + (1 − α) × EMA(t−1). The update is α × [C(t) − EMA(t−1)]. For N greater than 1, α exceeds 1/N, so the newest price has more direct influence than in SMA(N). On an ideal infinite history, the weight at age j is α(1 − α)j; for N = 20, ages 0, 1, 10 and 20 carry about 9.5238%, 8.6168%, 3.5007% and 1.2868%. A finite calculation also contains its chosen initial state; it does not include data preceding that start by magic.
With the stated first-close seed and the exact EMA5 multiplier 2/6, the five closes give an EMA of about 1.0852345679 and an SMA of 1.0842, a difference of about 10.35 pips. EMA gives greater weight to recent prices, but it is not always closer to the latest price and need not signal every directional change earlier than SMA.
Compare updates and distances on the same price path
Greater weight on the latest observation does not imply that EMA always lies closer to the price. Keep the input series, interval, period and initial state fixed before comparing the lines. Their readings, recognized signals and net trade results are separate measurements.
Reaction speed. Greater recent-price weight is a formula property; an earlier turn on every occasion is not. A signal test must specify how a turn is identified and account for when the value became available.
Take six hypothetical closes in arbitrary units: 100, 100, 100, 106, 94, 100. With N = 3, α = 0.5, seed EMA on bar 3 from the first SMA of 100; the first two readings are undefined in this convention.
| Bar | Close | SMA3 | EMA3 | Absolute distance: SMA / EMA |
|---|---|---|---|---|
| 3 | 100 | 100 | 100 | 0 / 0 |
| 4 | 106 | 102 | 103 | 4 / 3 |
| 5 | 94 | 100 | 98.5 | 6 / 4.5 |
| 6 | 100 | 100 | 99.25 | 0 / 0.75 |
On bar 6, SMA equals the latest close while EMA does not. This disproves “EMA is always closer,” without establishing SMA as a more profitable strategy. Adding a next close of 102 gives SMA3 = (94 + 100 + 102)/3 ≈ 98.6667 and EMA3 = 0.5 × 102 + 0.5 × 99.25 = 100.625. The relative distances can change again.
Crossovers and costs. Count crossings under a fixed definition on the same data. Their frequency and trading result depend on the path, holding rule and costs; neither EMA nor SMA has a universally better false-signal rate.
Long-term trend description. A long SMA or EMA summarizes historical prices under different weights. A popular SMA200 is one reference, but popularity does not prove superior performance or guarantee a price reaction.
A period counts bars; it does not prescribe a trading style
Periods such as 20, 50 and 200 are conventions. At roughly 20–22 daily sessions per month, 20 bars approximate one month, 50 a little over two months and 200 roughly nine to ten months. Translate bars into the actual market calendar rather than assume that 50 or 100 bars equal a quarter.
EMA needs an initial value. Fidelity describes starting from SMA; pinned TA-Lib v0.6.4 uses an SMA seed in its default compatibility mode, while an alternative first-price start is a different calculation, as in the five-close example above. With the same later inputs, an initial difference is multiplied by (1 − α)k after k updates. It does not disappear immediately after N bars. Compare implementations and version settings before interpreting a discrepancy as a new market signal.
Golden Cross and Death Cross — what they really mean
A Golden Cross conventionally describes a shorter average crossing above a longer one, often SMA50 above SMA200. A downward cross is called a Death Cross. State the exact average types and periods: the names describe observed crossings and do not guarantee a new trend.
A crossing describes an observed relationship between calculated lines. Popular Golden Cross examples use SMA50 and SMA200; replacing the short SMA with EMA changes the calculation. The crossing alone supplies neither a probability of a new bull market nor a compulsory trade direction. Define whether you use it as a condition, entry or exit, then test that exact rule.
EMA and SMA apply different weights to past prices. Their usefulness depends on the tested trading rule.
Specify a separate execution rule
A testable framework uses a long average as a directional filter, a medium average to define an observation zone and a shorter average as part of an entry rule. Its effectiveness depends on the specification, sample and costs; no author track record is asserted.
- Inputs and availability. Record each line’s feed, price source, interval, length and initial state; use only readings then available.
- Observation rule. Define the permitted side of a line or distance to it numerically. A pullback zone needs boundaries and a time limit, not merely a favorable-looking chart.
- Entry and cancellation. State what qualifies as the reaction, when an order becomes active and when it is canceled. A candle pattern processes related price data rather than provide automatically independent confirmation.
Choose exits, size and costs before evaluating outcomes. A planned 2:1 or 3:1 reward-to-risk ratio is an assumption about price levels, not evidence that the target is attainable or the strategy profitable. An ordinary stop may fill at a different price, and scaling out changes the payoff distribution. Preserve those execution choices when comparing EMA and SMA.
Check configuration before explaining a difference
A mismatch can come from the input window or implementation. Inspect the calculation before attributing it to market behavior or changing a trading rule.
- Window rotation. A rising SMA compares the new price with the dropped price, not necessarily the immediately previous close.
- Interval. SMA200 on M5 and D1 summarize different horizons. Neither is automatically meaningless or optimal.
- Initialization. A first-close start and an SMA seed leave different finite-history EMA readings.
- Price source and gaps. Check the feed, selected price and missing-data policy. EMA20 on H1 is not defined as a few weeks of prices.
- Test selection. Record all parameter variants tried and assess unused data. Familiar lengths and extra filters do not establish an edge; a fixed 200-pip distance supplies no universal continuation probability.
Compare on one fixed sample
Choose type and period for a stated rule, then compare alternatives on the same data and cost assumptions. A faster response can help or hurt depending on the rule. Neither an added indicator nor a familiar period automatically improves performance.
Conclusions
A useful distinction is the shape of the weights. Define the latest price’s age as 0, the preceding one as 1. SMA(N) has weighted mean age (N − 1)/2. For ideal infinite-history EMA, geometric weights give mean age (1 − α)/α, which is also (N − 1)/2 when α = 2/(N + 1). At N = 20, both mean ages are 9.5 bars, although the current price weights are 5% and about 9.5238%. EMA puts about (19/21)20 × 100 = 13.5110% on observations older than the latest twenty; SMA puts zero there. This own calculation does not measure crossing delay, identical line shape or profitable timing. A finite EMA additionally retains its initial-state influence.
A three-layer test can assign the daily SMA200 to a directional condition, EMA50 to an observation zone and a shorter EMA to entry timing. Define the relevant price reaction before collecting results. A widely watched line does not guarantee that price will react to it.
If a close-based test combines D1 and H4, preserve when the final daily reading became known. The completed daily value cannot be used earlier that same day merely because it appears on the finished chart. Record the signal and subsequent executable price separately. A filter can reject profits as well as losses, so evaluate all accepted and rejected observations under a fixed method.
What to do tomorrow
- Recalculate the counterexample. Use the six stated closes, N = 3 and SMA seed; check where SMA is closer. Then add the seventh close of 102 and recompute both values without resetting the EMA.
- Review the directional filter. Record whether your last thirty entries were above or below the daily SMA200. Compare results with your stated rule; the opposite side alone does not prove a trade should never have occurred.
- Test the pullback rule. Define the zone, trigger and invalidation point before observing outcomes. Track accepted and rejected signals and results after costs. Rejection count alone does not measure filter performance.
Related reading: moving averages — the mathematical comparison is the earlier, shorter version of this topic with more emphasis on the formulas; MACD — how to read the momentum indicator is built directly on the difference between two exponential averages; multi-timeframe analysis shows how to combine averages from different time frames into a single coherent system.
Check your understanding
One short exercise
About 2 min · you can try again
New close 105 replaces old 90 in SMA(3); prior close was 110. Why does SMA rise?
- 105 replaces 90 in the average update.
- Rising SMA proves price 105 is wrong.
- SMA gives the new price more weight.
Check the answer and explanation
105 replaces 90 in the average update.
(105−90)/3=+5 while the latest price change is −5.
Frequently asked
How does EMA mathematically differ from SMA?
SMA(N) equals the sum of N selected prices divided by N, each weighted 1/N. Standard EMA uses α = 2/(N + 1) and EMA(t) = α × C(t) + (1 − α) × EMA(t−1), with a stated initial value. Greater current-price weight is not an always-closer theorem: with closes 100, 100, 100, 106, 94, 100 and an SMA3 seed, the final SMA3 is 100 and EMA3 is 99.25. Infinite-history weight formulas must be distinguished from a finite seeded calculation.
When should I use SMA and when EMA?
Choose a measurable purpose and compare both types on the same feed, input price, interval, period and available history. Specify initialization and missing-data handling. A longer window summarizes a different horizon; no type is universally best for a style. For a trading test, keep entry, exit, size, costs and execution consistent and evaluate unused data. Additional averages do not automatically provide independent confirmation.
What are Golden Cross and Death Cross — are they worth trading?
Popular examples use SMA50 crossing above SMA200 for a Golden Cross and below it for a Death Cross. State both types and the interval; using EMA50 is a different calculation. A crossing describes past prices and does not guarantee a new regime or justify a compulsory direction. If the rule uses closes, assess it after the bar closes and model a later executable price. Efficacy depends on the specified rule, sample and costs.
Why is the 200-period average so important?
Two hundred is a conventional parameter rather than a special mathematical boundary. SMA200 on M5 covers 1000 minutes of bars, or 16 hours 40 minutes; breaks can extend calendar time. On D1 it covers 200 daily bars. Popularity does not establish a cluster of orders, a guaranteed bounce or optimal performance. State the intended horizon and evaluate any rule built around that line.
Sources & bibliography
-
John J. Murphy / Penguin Random House Technical Analysis of the Financial Markets (1999), chapter on moving averages · New York Institute of Finance, 1999; the chapter discusses moving averages. www.penguinrandomhouse.com ↗
-
Investopedia EMA vs SMA · Compares simple and exponential moving-average formulas with numerical examples. www.investopedia.com ↗
-
StockCharts ChartSchool Moving Averages — Simple and Exponential · Mathematical formulas and practical uses of simple and exponential moving averages. chartschool.stockcharts.com ↗
-
Federal Reserve Bank of St. Louis (FRED) EUR/USD historical exchange rate · An identified historical EUR/USD exchange-rate series for examining moving-average crossover examples. fred.stlouisfed.org ↗
-
Fidelity Exponential Moving Average (EMA) · Describes the recursive update and an SMA initial value. The lesson supplies its own counterexample to distinguish greater recent-price weight from an always-closer line or earlier profitable signal. www.fidelity.com ↗
-
TA-Lib EMA implementation, version 0.6.4 · Pinned implementation documents the default SMA seed and a different compatibility-mode start. Used to explain version and initialization differences; the worked models are arithmetic examples rather than native-library results. raw.githubusercontent.com ↗
-
TradingView Moving Averages · Documents SMA windows, the standard EMA multiplier, price source, offset and average crossovers. The lesson distinguishes calculation definitions from universal trading recommendations or guaranteed price reactions. www.tradingview.com ↗
