A moving average smooths a security's price by averaging it over a set number of periods. Traders and analysts use it to see the direction of a trend and to define rules for entries and exits. This guide explains the types of moving average, the rules commonly built on them, their limits, and how to test such a rule on historical data. It is a description of a technical tool and does not suggest that any rule will be profitable.
Related guide: Technical Indicators: A Guide to Trend, Momentum, Volatility and Volume
What is a moving average?
A moving average takes the last N closing prices, calculates their average, and recalculates it each period as new prices arrive. The result is a line that moves more slowly than price. A rising line is read as an uptrend and a falling line as a downtrend. For more detail, see What are moving averages.
See what markets are pricing in
Live indices, sector moves and market breadth — the backdrop to every story we publish.
Types of moving average
Simple moving average (SMA)
The SMA adds the closing prices of the last N periods and divides by N. Every price has equal weight. For a 5-day SMA with closes of 100, 102, 101, 103 and 104, the value is 510 / 5 = 102. The SMA is easy to calculate but reacts slowly to new prices.
Exponential moving average (EMA)
The EMA gives more weight to recent prices. It is calculated as: EMA today = (Price today x k) + (EMA yesterday x (1 - k)), where k = 2 / (N + 1). For N = 10, k is about 0.18. Because recent data counts more, the EMA responds faster than the SMA of the same length, at the cost of more false signals.
Other variants
- Weighted moving average (WMA) assigns linearly declining weights to older prices.
- Adaptive moving averages change their speed based on how trending or noisy the market is.
Common periods
Periods of 10, 20 and 50 days are described as short-to-medium term, while 100 and 200 days are used for long-term trends. These are conventions, not rules. The 200-day average is widely watched, partly because many market participants follow it.
Rules commonly built on moving averages
Price versus moving average
A basic rule treats a close above the moving average as bullish and a close below it as bearish. Some analysts also treat a rising average as support in an uptrend and a falling one as resistance in a downtrend.
Crossovers
A crossover rule compares a shorter and a longer average. When the short one moves above the long one, the rule flags a possible uptrend, and when it moves below, a possible downtrend. The pair of 50-day and 200-day averages is known as the Golden Cross (50 above 200) and the Death Cross (50 below 200).
Envelopes
A moving average envelope draws bands a fixed percentage above and below a moving average. Price touching the outer bands is read as stretched relative to the average.
Ribbons
A ribbon plots several moving averages of different lengths. When they fan out in the same direction the trend is described as strong, and when they converge the trend is described as weakening.
Get research like this in your inbox
The week’s research that mattered, in five minutes. Joined by 2L+ investors.
Building a rule: the decisions involved
- Type of average. SMA or EMA, since each reacts at a different speed.
- Length. Shorter averages give more signals and more noise, and longer ones give fewer, later signals.
- Signal definition. A close above the average, a crossover, or a combination with another indicator such as RSI or MACD.
- Exit and risk rules. A stop-loss level, a position-size limit or an opposite signal.
- Testing. Running the rule on historical prices, including costs. See the guide to backtesting.
Strengths and limits
Strengths
- Clarity. The calculation is transparent and rules are easy to define.
- Noise reduction. Smoothing removes day-to-day movements.
- Flexibility. The same tool applies to stocks, indices, commodities and currencies and to any time frame.
Limits
- Lag. A moving average is built from past prices, so signals arrive after a trend has started and after it has ended.
- Whipsaws. In sideways markets price crosses the average repeatedly, producing many signals that reverse.
- Parameter sensitivity. Results can differ greatly between, say, a 45-day and a 55-day average, which is a warning sign of overfitting if a rule only works for one setting.
- Costs. Frequent signals mean frequent trades, with brokerage, taxes and slippage reducing net returns.
Worked examples
Example 1: 50-day and 200-day crossover
Suppose a stock's 50-day SMA rises above its 200-day SMA. The rule flags a Golden Cross. The rule's exit is defined in advance, for instance when the 50-day SMA falls back below the 200-day SMA. The signal says nothing about how far the price will travel after the crossover, and because both averages are slow, much of a move may have occurred before it triggers.
Example 2: 10-period and 50-period EMA on an intraday chart
An intraday rule might flag a long position when a 10-period EMA crosses above a 50-period EMA, with a stop below the recent swing low and an exit on the opposite cross. On short time frames, spreads and costs are a larger share of each move, and signals reverse more often.
Testing and evaluating a rule
When a rule is tested on past data, the usual measures are the number of trades, average gain and loss, maximum drawdown (the largest fall from a peak), and results after costs. Testing across different periods, including strong trends, falling markets and sideways markets, shows whether results depend on one regime. A rule tested over a few years in a rising market can look better than it would over a full cycle. Out-of-sample testing, where parameters are chosen on one period and checked on another, reduces the chance of overfitting. See how trading strategies are built and tested.
Is your portfolio built for what’s coming?
Get a free AI-powered review of your holdings — risk, overlap and quality in minutes.
Frequently asked questions
What is the difference between SMA and EMA?
The SMA weights all periods equally. The EMA weights recent prices more, so it follows price more closely and reverses direction sooner.
Can moving averages be used on any security?
The calculation works on any price series. How well a rule performs depends on the security's liquidity and on whether it tends to trend.
Are moving averages used in intraday charts?
Yes. They are applied on one-minute to hourly charts as well as daily and weekly charts, with shorter lengths on shorter time frames.
What are common mistakes in using them?
- Using a single indicator without considering market conditions.
- Ignoring lag and costs.
- Choosing the setting that fit past data best without testing it elsewhere.
Related reading: Market Sentiment: Meaning, Indicator, Types and Strategies, What is High-Frequency Trading (HFT), Risk Management with Candlestick Patterns and Trade to Trade (T2T) Stocks.
This article is for educational purposes only and is not investment advice.