Author: Analyst Lu Mingyu
First establish what the 20 periods represent
Even when both indicators are set to 20 periods, a simple moving average (SMA) and an exponential moving average (EMA) normally do not coincide. SMA gives equal weight to the prices of the latest 20 bars included in its calculation. EMA puts more weight on new prices and carries the earlier average into each subsequent calculation. The distinction comes from the formulas, not evidence that the line turning first predicts gold prices better.
The setting 20 means 20 chart periods, not automatically 20 calendar days. On a daily chart it normally refers to 20 daily candles, while on a one-hour chart it means 20 hourly candles. Before comparing lines, align the instrument, quote provider, chart timeframe, price input (such as the close), candle boundaries and treatment of an unfinished bar. Two platforms can both show 20 yet be calculating from different inputs.
This article considers the common setting that uses closing prices. Choosing the open or another price series changes the calculation. For background on what moving averages say about past prices and trends, see the site’s introduction to moving averages. The focus here is why two algorithms with the same period can report different readings.
SMA assigns equal weight to every bar in its window
SMA adds the latest N input prices and divides the result by N. For a 20-period SMA, every included price has a weight of one twentieth. When a new bar enters, the earliest bar leaves the rolling window. An unusually high input affects the average for as long as it remains in that window; once removed, its contribution disappears. SMA is an arithmetic mean of its inputs, not investors’ actual average holding cost, and a price approaching the line does not automatically create support.
TradingView’s official guide to SMA and EMA explains equal weighting and exponential weighting. These formulas establish how the lines are drawn; whether a support level or tradable trend exists still requires separate examination of price structure and risk conditions.
EMA gives greater weight to recent prices
A common recursive formula is: current EMA = previous EMA + α × (current close − previous EMA), where α = 2 ÷ (N + 1). For N = 20, α is approximately 0.0952, so the current price has a direct weight of about 9.52% in the new EMA, compared with 5% for each observation in a 20-period SMA. EMA also incorporates the previous EMA: older data fade gradually instead of dropping out completely when the 21st observation arrives. The initial EMA value and starting point of the available history may produce small early differences between platforms.
For a purely hypothetical demonstration, assume five completed consecutive hourly gold candles have closing prices of 100, 100, 100, 106 and 100 USD per ounce, recorded in Beijing time. These are teaching figures, not live quotations or actual history. Temporarily use a three-period length and seed EMA with the SMA of the first three closes, 100:
| Completed bar | Close (USD/oz) | 3-period SMA | 3-period EMA |
|---|---|---|---|
| Bar 3 | 100 | 100 | 100 |
| Bar 4 | 106 | 102 | 103 |
| Bar 5 | 100 | 102 | 101.5 |
For bar 4, EMA = 100 + 0.5 × (106 − 100) = 103, whereas SMA = (100 + 100 + 106) ÷ 3 = 102. When bar 5 closes back at 100, EMA = 103 + 0.5 × (100 − 103) = 101.5, while SMA remains (100 + 106 + 100) ÷ 3 = 102. This illustrates how weighting changes the response. It does not justify transplanting the three-period difference into a 20-period setting or forecasting what gold will do next.
The lines can also temporarily converge. If every input stays identical and the EMA seed equals that price, both indicators show the same value. A later price change separates them according to their weighting. Even if the price returns to its original level, SMA must wait for earlier values to exit its window, while EMA gradually absorbs the previous disturbance. Overlap today and separation tomorrow do not by themselves imply that new market news has arrived.
Does faster EMA response make it better for trading?
Not necessarily. Because EMA emphasizes newer data, it often moves toward a sudden price change more quickly, but in choppy markets its slope can also switch direction more frequently. SMA is relatively smooth, though removing an older extreme value from its window can itself change the line. Both are lagging indicators calculated from historical prices. Which one turns first says nothing conclusive about returns without accounting for spreads, slippage, exit rules and failed signals.
Compare both indicators on the same instrument, timeframe and input series, and record whether readings were taken from a live bar or after that bar closed. The current price of an unfinished candle can keep changing the indicator; see the site’s article about unclosed candlesticks. If platforms disagree, examine their quotation sources, trading sessions, missing bars, price inputs, historical starting points and formula settings instead of treating the discrepancy as a new market signal.
Ideally, select one completed candle and record its Beijing-time timestamp, close and indicator values; then locate the equivalent bar on the other chart. Spot gold and another gold contract, or daily candles using different session cutoffs, need not produce equal 20-period values. Align the underlying data before judging the calculation. Because EMA recursively incorporates its earlier value, two platforms can differ briefly even if their most recent 20 closes appear identical, when earlier history or the initial value differs.
When reviewing trades, distinguish different line values from a valid entry condition. If price crosses SMA and EMA at different moments intrabar, that only shows two historical-price reference levels at different locations. A strategy requiring an hourly candle to close must not be rewritten into an intrabar-touch rule just because EMA was touched first. Waiting for a close cannot guarantee continuation either. Predefined rules establish an auditable basis for reviewing what happened.
Neither line provides a risk-free price level
Moving averages are summaries of price data. Even if a quote moves across a line, the observed quote, submitted order price and executed price may differ, and margin trading can magnify losses. Any rules based on a moving average should specify which completed bar confirms the signal, when that signal becomes invalid and what losses are bearable. The site’s article on stop-loss risk explains why a very tight stop is not automatically safer. Understanding SMA versus EMA is useful, but neither provides a trading guarantee.

