Moving averages explained: SMA, EMA and crossovers
How simple and exponential moving averages are calculated, how traders use them for trend and dynamic support, and what crossovers can and cannot do.
Smoothing the price
A moving average replaces the jagged line of closing prices with a smoother line by averaging the last few values. Each new candle adds a new value and drops the oldest one, so the average "moves" with the chart. It is the most widely used indicator in the world because it answers a simple question clearly: which way is the price trending, and how strongly?
Simple moving average (SMA)
The SMA is the plain average of the last n closes. A 20-period SMA on a daily chart is the average close of the last 20 days. Every value inside the window counts equally.
SMA = (close[0] + close[1] + ... + close[n-1]) / n
Because every value has the same weight, the SMA reacts slowly and changes when an old, large move drops out of the window - sometimes moving even though today's price did nothing.
Exponential moving average (EMA)
The EMA gives more weight to recent prices. Each new value is a blend of today's close and yesterday's EMA:
k = 2 / (n + 1)
EMA = close * k + EMA[1] * (1 - k)
The result follows the price more closely and turns sooner than an SMA of the same length. The price of that speed is more false turns in sideways markets.
Choosing the length
Short averages (8 to 21 periods) follow the price closely and suit short-term trends. Medium averages (50) describe the intermediate trend. Long averages (100 and 200) describe the big picture; the 200-day SMA is watched by so many market participants that the price often reacts around it. There is no magic number - pick a few lengths and use them consistently.
Three common uses
1. Trend direction
Price above a rising average suggests an uptrend; price below a falling average suggests a downtrend. A flat average with price weaving around it means there is no clear trend - a warning that trend-following signals will be unreliable.
2. Dynamic support and resistance
In a steady trend, pullbacks often stop near a moving average, such as the 20 or 50 EMA. Traders watch these areas for signs of the trend resuming.
3. Crossovers
When a faster average crosses above a slower one (for example the 9 EMA above the 21 EMA), momentum has turned up; a cross below means it turned down. The famous "golden cross" (50-day above 200-day) and "death cross" (50-day below 200-day) are slow versions of the same idea.
Be realistic: crossovers are lagging by design - they confirm a move after it has started. In trending markets they catch big moves; in sideways markets they produce many small losing signals. Filter them with the higher-timeframe trend or with support and resistance.
Moving averages on TradeMuv
Open Indicators in the top bar and add Moving Average or EMA - as many as you like. Each has its own length, source, colour and line style, and you can choose on which timeframes it appears (for example show the 200 EMA only on hourly and higher charts). If you prefer to write your own, a moving-average crossover is the classic first Pine Script; see your first Pine Script indicator.
Test before you trust
Before using a moving-average rule with real money, replay several months of history with bar replay or test it with the strategy tester. Count how many signals worked, how large the losses were, and how it behaved in sideways periods. A rule you have tested yourself is much easier to follow.
One account. Every screen.
TradeMuv is the free trading chart platform: live charts, footprint and order flow, bar replay, paper trading, Pine Script, unlimited indicators and alerts - on your computer, tablet and phone, with one free account.
Explore all TradeMuv featuresFree · no card · no downloadEverything in this guide works in TradeMuv, free - no card, no trial.
Create free accountThis guide is for education only and is not financial advice. Trading involves risk. Risk disclaimer.
Keep learning
How the Relative Strength Index is calculated, what overbought and oversold really mean, and how to use RSI divergence and ranges.
6 min readPracticeHow to practise trading with bar replayBar replay hides the future and plays the market candle by candle. A step-by-step routine to practise reading charts and testing ideas without risk.
6 min readPracticeHow to paper trade: practise trading without risking moneyWhat paper trading is, how to start a free demo account on live charts, a practice routine that builds real skill, and the mistakes that mislead.
7 min read