Moving Averages Explained: SMA vs EMA Formulas, Crossovers and Dynamic Support
Lesson 4 of 10 · Beginner
What a moving average is
A moving average takes the average of the last several prices and, as each new candle arrives, drops the oldest data point. The result is a smooth line that reduces noise and shows the general direction. The price of that smoothness is lag: an average always turns later than price does.
Simple moving average (SMA)
The SMA is the sum of the last n closing prices divided by n: SMA = (C1 + C2 + … + Cn) / n. Every candle has equal weight, so when one large candle drops out of the window the line can jump for no apparent reason. The approximate lag of an SMA is (n−1)/2 candles, which means a 20-period SMA is roughly showing where the average was about ten candles ago.
Exponential moving average (EMA)
The EMA gives more weight to recent data: EMA = price × k + previous EMA × (1 − k), where k = 2 / (n + 1). For a 20-period EMA, k is about 0.095. The EMA reacts faster, and for that very reason it also produces more false signals. Neither is “better”; the choice is between responsiveness and stability.
Common periods and what they are used for
| Period | Common use |
| 9 and 21 (usually EMA) | Short-term momentum and intraday pullbacks |
| 20 and 50 | Medium-term trend; popular on the 1-hour and 4-hour charts |
| 100 and 200 | Long-term trend; the 200-day SMA in particular is watched by many market participants |
These numbers are not sacred. Part of the importance of the 200-day average is simply that many people look at it, and that shared attention sometimes creates a reaction. Gold trades nearly 24 hours, and the time at which the “day” closes differs between platforms (for example, a 5 pm New York close versus a broker server-time close), so daily average values can differ slightly between brokers. Treat an average as a zone a few dollars wide rather than an exact level.
Three main uses of moving averages
- Direction filter. Price above the average with a rising slope suggests a bullish bias, and the reverse for bearish. Slope matters more than where price sits at a given moment; price weaving above and below a flat average means a market with no trend.
- Dynamic support and resistance. In orderly trends, pullbacks often stall near a particular average. This is not constant: in a strong trend the 20 EMA may hold again and again, and in the next phase price may pull back to the 50 or 100 SMA. See the average as a zone, not a precise line.
- Crossovers. A shorter average crossing a longer one. The best known are the golden cross (the 50 SMA crossing above the 200 SMA) and the death cross (the opposite). Because both lines are slow, the cross usually appears after a substantial part of the move; it suits long-term regime identification better than precise timing.
A less-discussed use is distance from the average. When price stretches far from its average, the move is “extended” and the chance of a pause or a return toward the average rises; but in strong trends, extension can last a long time.
Hypothetical gold example
The numbers are hypothetical. On the 1-hour XAUUSD chart the 20 EMA sits at 3865 and the 50 EMA at 3848, both sloping upward. Price pulls back from 3900 to 3867, the area of the 20 EMA. The analyst's question is whether price holds this zone. If candles close above it and the higher-low structure survives, the trend-continuation scenario stays valid. If price closes below the 50 EMA at 3848 and the 20 EMA starts to flatten, the trending regime is in doubt and it is better to wait for a new structure to form.
Pay attention to the order of the averages too. When price is above the 20 EMA, the 20 is above the 50 and the 50 is above the 200 SMA, the averages are “stacked” and the trend is aligned across horizons. When the averages are tangled and keep swapping places, the market is probably ranging or transitioning, and trend tools carry less weight.
Weak spots: ranges and lag
Moving averages are trend tools and perform poorly in ranges. When price oscillates inside a horizontal band, crossovers fire one after another with no follow-through (whipsaws), and each cross usually appears near the end of a small swing. Some ways to reduce the problem: check the slope of the longer average, use the gap between two averages as a measure of trend strength, or combine with a tool that identifies the market regime. None of these fully removes lag; lag is the inherent cost of smoothing.
Another common temptation is searching for the “best period” by testing on past data. If you try dozens of combinations, one will look great on history purely by chance. That is overfitting, and it usually does not repeat. It is better to pick standard, sensible periods and test them on a separate sample that played no part in the selection.
Common mistakes
- Optimizing the average's period on past data to get the best result (overfitting).
- Trading every crossover in a ranging, trendless market.
- Expecting an exact bounce from the average line instead of a zone.
- Using several averages that are close together and give nearly the same information.
- Ignoring the slope of the average and looking only at whether price is above or below it.
What does volume say here?
A moving average weights prices only by time, but the market does not work that way: a price at which thousands of contracts traded is not equal to a price where only a few changed hands. VWAP, the volume-weighted average price, corrects exactly this. It shows the session's average price paid, weighted by volume, and many institutional traders use it as a benchmark for execution quality. An anchored VWAP, started from a significant swing low or high, shows whether participants who entered from that point are on average in profit or at a loss.
A practical combination: when a pullback stalls in an area where the 20 EMA and the session VWAP are close together, two different kinds of evidence overlap. If heavy selling delta appears in that same area but price does not go lower, it points to buyers absorbing the selling. Conversely, a break through the EMA on high volume with price holding below VWAP suggests that this time the average probably will not hold. None of this is conclusive, but together they carry more meaning than either alone. For gold, real volume for VWAP comes from COMEX GC futures, converted to XAUUSD with the basis; CFD volume is tick volume.
📊 See real gold futures volume behind these ideas: free order flow course · today's gold volume map
Frequently asked questions
Is EMA better than SMA?
Neither is better in absolute terms. The EMA reacts faster and gives more false signals; the SMA is calmer and steadier. The choice depends on your style and timeframe and should be tested.
What is the best moving average period for gold?
There is no fixed best period. Common settings such as 20, 50 and 200 are useful because many participants watch them. Test any choice on a separate sample and avoid extreme optimization.
Is a golden cross a buy signal?
A golden cross is better seen as a long-term regime change than an entry point. Because both averages lag, it often appears after a large part of the move, and in a range it can repeat many times with no result.
Education only, not a recommendation to buy or sell; we never give signals. Price examples are illustrative. Test any method on a demo account first, with strict risk management.