Academy · · 12 min · By Álvaro García
Moving Averages Explained: SMA vs EMA, Formulas and Uses
Moving averages explained: SMA and EMA formulas with a worked example, the 20-, 50- and 200-day periods, golden and death crosses, and common mistakes.

In short: a moving average is the average price over the last N periods, recalculated with every new candle: it smooths out the noise and shows which way the trend is heading. The simple moving average (SMA) gives every close the same weight; the exponential moving average (EMA) gives more weight to recent closes and reacts faster. The most closely watched is the 200-day: below it, the market considers an asset to be in a downtrend.
A moving average is the arithmetic (or weighted) average of an asset's most recent closing prices, updated with every new candle by adding the latest data point and dropping the oldest. It shows the direction of the trend without the day-to-day noise, and it is one of the most widely used technical indicators, from the forex trader watching 5-minute charts to the fund manager deciding whether to cut equity exposure.
In this guide you will find the formulas for the simple and exponential moving average with a step-by-step worked example, which periods different kinds of traders use, how to read crossovers (the famous golden cross and death cross), the costliest mistakes and a real case: how Nvidia looks against its 200-day moving average right now.
What is a moving average in trading?
A moving average in trading is a line that plots, candle by candle, the average price of the last N periods. If price is above a rising average, the trend is up; if it is below a falling average, the trend is down. It is a lagging trend indicator: it confirms what has already happened; it does not predict what will happen next.
It is called "moving" because the calculation window rolls forward in time. A 20-day moving average calculated today uses the closes of the last 20 sessions; tomorrow the new close comes in and the one from 21 sessions ago drops out. That is why the line shifts and curves with price, but more smoothly.
The number of periods (N) depends on the chart's timeframe. On a daily chart, the 50-period average covers 50 sessions (about two and a half months of trading); on an hourly chart, it covers 50 hours. The formula is the same: the only thing that changes is what each candle represents.
Types of moving averages: simple, exponential and others
Trading platforms offer four main types. The official MetaTrader 5 help pages set out these formulas; they differ in how they split the weight between older and more recent prices.
- Simple moving average (SMA): every close carries the same weight. It is the most widely used in equities and the benchmark when the financial press talks about "the 200-day moving average".
- Exponential moving average (EMA): gives more weight to the latest closes, so it turns sooner when the trend changes. It is the favourite in forex, crypto and intraday trading.
- Linear weighted moving average (LWMA or WMA): the most recent close has a weight of N, the previous one N−1, and so on down to 1. Over short periods it reacts even faster than the EMA.
- Smoothed moving average (SMMA): very slow and stable; it underpins Wilder's calculation of the RSI indicator.
How to calculate the simple moving average (SMA)
The formula is: SMA = (P1 + P2 + … + PN) / N, where P is the close of each of the last N periods. You add up the closes and divide by how many there are.
How to calculate the exponential moving average (EMA)
The formula is: EMAtoday = Closetoday × α + EMAyesterday × (1 − α), with the smoothing factor α = 2 / (N + 1). To get started, the first EMA is usually the SMA of the first N closes. From then on, each value incorporates all the previous ones, with weights that decay gradually.
The factor α tells you how much the latest close weighs in the EMA. It is the figure that best explains why a short EMA is jumpy and a long one barely moves:
| EMA period | α = 2/(N+1) | Weight of latest close |
|---|---|---|
| 9 | 2/10 | 20.0% |
| 12 | 2/13 | 15.4% |
| 20 | 2/21 | 9.5% |
| 26 | 2/27 | 7.4% |
| 50 | 2/51 | 3.9% |
| 100 | 2/101 | 2.0% |
| 200 | 2/201 | 1.0% |
In a 200-day SMA, by contrast, every close weighs exactly 1/200, or 0.5%, whether it is yesterday's or one from ten months ago.
Worked example: 5-period SMA and EMA step by step
Take a stock with these daily closes: $100, $102, $101, $104 and $108. We will calculate its 5-period SMA and 5-period EMA over three more days, on which it closes at $110, $107 and $100.
- Day 5 (starting point). SMA = (100 + 102 + 101 + 104 + 108) / 5 = 515 / 5 = 103.00. We use that same value as the first EMA: 103.00. The factor for a 5-period EMA is α = 2/6 = 1/3.
- Day 6, close 110. The 100 drops out and the 110 comes in. SMA = (102 + 101 + 104 + 108 + 110) / 5 = 525 / 5 = 105.00. EMA = 110 × 1/3 + 103.00 × 2/3 = 36.67 + 68.67 = 105.33.
- Day 7, close 107. SMA = (101 + 104 + 108 + 110 + 107) / 5 = 530 / 5 = 106.00. EMA = 107 × 1/3 + 105.33 × 2/3 = 35.67 + 70.22 = 105.89.
- Day 8, close 100 (a 6.5% drop). SMA = (104 + 108 + 110 + 107 + 100) / 5 = 529 / 5 = 105.80. EMA = 100 × 1/3 + 105.89 × 2/3 = 33.33 + 70.59 = 103.93.
| Day | Close | 5-period SMA | 5-period EMA |
|---|---|---|---|
| 5 | 108 | 103.00 | 103.00 |
| 6 | 110 | 105.00 | 105.33 |
| 7 | 107 | 106.00 | 105.89 |
| 8 | 100 | 105.80 | 103.93 |
Look at day 8. The stock falls sharply, yet the SMA barely moves, from 106.00 to 105.80, because the close dropping out (101) and the one coming in (100) are almost identical. The EMA, on the other hand, falls by almost two dollars, from 105.89 to 103.93, because the new close carries a third of the weight. That is the practical difference: the SMA also depends on the data point leaving the window; the EMA depends only on the one arriving.
It also explains the lag: an N-period SMA trails price by (N − 1)/2 periods on average (2 sessions for a 5-period average; 99.5 for a 200-period one). The EMA and the weighted average, which load the weight onto the latest data, lag less.
That detail has a consequence few guides explain: an SMA can move "on its own" because of the data point leaving the window. If there was a huge up day 200 sessions ago, the 200-day SMA will fall when that day drops out of the calculation, even if the current price does nothing.
How to calculate a moving average in Excel or Google Sheets
Put the dates in column A and the closes in column B, starting in row 2. For a 5-period SMA, type =AVERAGE(B2:B6) in C6 (in Spanish-language Excel, =PROMEDIO(B2:B6)) and drag it down: the window rolls forward automatically.
For a 5-period EMA, use the first SMA as the seed: type =C6 in D6 and =B7*2/6+D6*(1-2/6) in D7, then drag it down. With the closes from the example above you will get exactly 105.33, 105.89 and 103.93.
SMA vs EMA: which moving average is better?
Neither is better in every case. The EMA reacts faster and gives earlier signals, at the cost of more false signals in sideways markets. The SMA is slower but more stable, and it is the one most of the market watches on daily charts, especially the 50-day and the 200-day.
A useful rule of thumb: use whichever the rest of your market uses. Technical levels work partly because many traders watch them at the same time. In stocks and indices, the 200-day SMA is the one that makes headlines; in forex and crypto, the 20-, 50- and 200-period EMAs are common.
Best moving average periods: 9, 20, 50, 100 and 200
There is no magic period, but there are standard settings that keep coming up because they are the ones most people watch:
| Period | Horizon | Typical use |
|---|---|---|
| 9-10 | Very short term | Intraday and scalping; tracking the momentum of the latest candles |
| 20-21 | Short term (one month of trading) | Swing trading; the middle line of the Bollinger Bands |
| 50 | Medium term (one quarter) | Intermediate trend; the faster line in the golden cross |
| 100 | Medium to long term | Intermediate support or resistance in indices |
| 200 | Long term (about ten months) | The dividing line between a long-term uptrend and downtrend |
As a general rule: the shorter your horizon, the shorter the average. And never use more than two or three at once: the chart fills up with lines that contradict each other.
How to use moving averages in trading
1. Trend filter
The simplest and most useful application: you only look for longs when price is above the 200-day average and the average is rising, and only for shorts when price is below it and it is falling. It does not give you the entry point, but it keeps you from trading against the prevailing trend.
2. Dynamic support and resistance
In clear trends, price often pulls back to the 20- or 50-period average and bounces off it. That is why many traders wait for that pullback to enter rather than chasing price. Be careful: it is a zone, not an exact line, and price often pierces it by a few ticks before turning.
3. Moving average crossovers: golden cross and death cross
A golden cross happens when the 50-day moving average crosses above the 200-day; a death cross, when it crosses below. As CMC Markets explains, both are lagging signals: by the time they appear, price has been moving in that direction for weeks.
Crossovers of two shorter EMAs (for example, 9 and 21) follow the same logic on lower timeframes. The MACD indicator, in fact, is simply the difference between a 12-period EMA and a 26-period EMA.
4. Distance from the average
When price moves a long way from its average, the move is usually "stretched". That is not a reversal signal on its own, but it is a warning that the risk of a bounce (or a pullback) has increased. Measuring it is simple: distance = price / average − 1.
200-day moving average: a real-world example with Nvidia (November 2026)
Nvidia's slide in November 2026 is a textbook example of how the market reads the 200-day moving average. According to Benzinga, via TradingView, on 9 November the stock was trading at $177.80, around 13% below its 200-day moving average ($204.61), the widest gap since late April 2025. Back then, after the "Liberation Day" tariffs, it closed as much as 25.8% below it, on 4 April 2025.
The decline has continued since. On Wednesday 18 November Nvidia fell 2.9% to $150.96, according to Euronews, on track for its seventh straight weekly loss, the longest losing streak since July 2008 (we analyse it in Nvidia's losing streak). A 200-day average barely changes in a week, because each session adds only one new close and drops the oldest one. As a rough calculation, if it were still around $204.61, the distance would be 150.96 / 204.61 − 1 ≈ −26%, close to the April 2025 extreme.
What the case teaches us:
- The trend filter worked as a warning. Anyone who only bought above the 200-day average stopped doing so when price lost it, weeks before the mid-month lows.
- Being far from the average is not a buy signal. An extreme distance tells you the sell-off is stretched, not when it will end. With the average near $204.61, getting back to it from $150.96 would require a rise of about 35.5%.
- Moving averages do not anticipate news. Neither Jensen Huang's resignation as chief executive (12 November) nor the tightening of chip export rules shows up on any line: price reacts first and the average follows.
This example is for educational purposes only. It is not a recommendation to buy or sell Nvidia shares.
Common mistakes with moving averages
- Using them in a sideways market. Without a trend, price crosses the average again and again, and every crossover is a false signal. This is the main source of losses for crossover strategies.
- Curve-fitting the period to past data. Searching for the "perfect" average (the 37, the 143) that worked best on a particular chart almost never carries over to the future.
- Treating the average as an exact line. Price can pierce it and come back; placing your stop just above or below it often gets it triggered by noise. If you use it as a reference, leave a reasonable buffer, as we explain in our stop loss guide.
- Forgetting that it lags. A 200-day average confirms the trend months after it starts. It is a filter, not a tool for catching tops and bottoms.
- Ignoring position size. A good signal with a position that is too big is still a bad trade. Before entering, work out how much you are risking with the position size calculator.
Remember that trading with leverage, CFDs or cryptocurrencies can make you lose money faster than you expect: no moving average removes that risk.
Summary table: SMA vs EMA
| Simple moving average (SMA) | Exponential moving average (EMA) | |
|---|---|---|
| Formula | Sum of N closes / N | Close × α + previous EMA × (1 − α), with α = 2/(N+1) |
| Weighting | Equal for all | Higher for recent data |
| Speed | Slow | Fast |
| False signals | Fewer | More in sideways markets |
| Typical use | Stocks, daily chart, 50- and 200-day averages | Forex, crypto, intraday, MACD |
Frequently asked questions
What does it mean when a stock is below its 200-day moving average?
It means its current price is below the average close of the last 200 trading days, about ten months. The market reads it as a long-term downtrend. It does not predict further falls, but many funds and traders cut exposure or stop buying in that situation.
What is the best moving average for day trading?
Intraday traders tend to use short EMAs, 9 or 20 periods, on 5- to 15-minute charts, combined with a slower one (50 or 200) as a trend filter. What matters is consistency: the same system, tested on a demo account before using real money.
How do you add a moving average in MetaTrader or TradingView?
In MetaTrader 5, go to Insert, Indicators, Trend, Moving Average; choose the period, the method (Simple, Exponential, Smoothed or Linear Weighted) and the price (usually the close). In TradingView, click Indicators and search for "Moving Average" (SMA) or "EMA".
Do moving averages work for crypto?
Yes, they are calculated the same way. The difference is that crypto trades 24 hours a day, seven days a week, so a 200-period average on a daily chart covers 200 calendar days, not roughly ten months of stock market trading. Higher volatility also produces more false signals.
What is a golden cross?
It is when the 50-day moving average crosses above the 200-day. It is seen as a sign of an uptrend, although it comes late: by the time it happens, price has already been rising for weeks. Its opposite is the death cross, when the 50-day crosses below the 200-day.