Skip to main content
Blog home
Newsletter
News
Video
Podcast
Reading list
Wright Brief
Sign In

Moving Average Trading Strategy to Buy Stocks

How simple and exponential moving averages are calculated, how crossover rules are built, their limits such as lag and whipsaws, and how rules are tested.

Listen to this article
Audio · ~6 min
Add as a preferred source on Google
Discover the simplicity and effectiveness of moving average trading strategies. Learn how to use SMAs and EMAs to identify trends, determine buy/sell points, and enhance your trading performance. Perfect for both novice and experienced traders.

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.

Free tool

See what markets are pricing in

Live indices, sector moves and market breadth — the backdrop to every story we publish.

Open Market Tracker

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.

Find bull market portfolios that are beating the market.
Explore Now
The Wright Brief · free weekly

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

  1. Type of average. SMA or EMA, since each reacts at a different speed.
  2. Length. Shorter averages give more signals and more noise, and longer ones give fewer, later signals.
  3. Signal definition. A close above the average, a crossover, or a combination with another indicator such as RSI or MACD.
  4. Exit and risk rules. A stop-loss level, a position-size limit or an opposite signal.
  5. 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.

Find bull market portfolios that are beating the market.
Explore Now
Free tool

Is your portfolio built for what’s coming?

Get a free AI-powered review of your holdings — risk, overlap and quality in minutes.

Review my portfolio

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.

Disclaimer: Investment in securities market are subject to market risks. Read all the related documents carefully before investing. Registration granted by SEBI, membership of a SEBI recognized supervisory body (if any) and certification from NISM in no way guarantee performance of the intermediary or provide any assurance of returns to investors.

The content in these posts/articles is for informational and educational purposes only and should not be construed as professional financial advice and nor to be construed as an offer to buy/sell or the solicitation of an offer to buy/sell any security or financial products. Users must make their own investment decisions based on their specific investment objective and financial position and using such independent advisors as they believe necessary.

Wryght Research & Capital Pvt (Brand name: Wright Research) is a SEBI Registered Portfolio Manager Reg No: INP000007979 (Validity: Apr 03, 2023 – Perpetual) and a SEBI Registered Research Analyst No: INH000017295 (Validity: Jul 03, 2024 – Perpetual), with its registered office at 103, Shagun Vatika Prag Narayan Road, Lucknow, UP, 226001 India and CIN: U67100UP2019PTC123244. Past performance may or may not be sustained in future. Performance provided there in is not verified by SEBI. Investment in securities is subject to market and other risks, and there is no assurance or guarantee that the objectives of any of the strategies of the Portfolio Management Services will be achieved. Registration granted by SEBI, enlistment as RA with Exchange and certification from National Institute of Securities Markets (NISM) in no way guarantee performance of the intermediary or provide any assurance of returns to investors. Please read the Disclosure document carefully before investing. Securities quoted are for illustration only and are not recommendatory. Charts shown are for illustration only. For more information and disclosures, visit our disclosures page here.

Found this useful? Share it.
Explore related topics
About the author
Madhav Agarwal
Wright Research
Wright PMS · Portfolio Management Service

Put this research to work

The same 300+ factor research engine behind this article — applied to a professionally managed portfolio, end to end.

300+
Factors tracked
2L+
Investors
₹1,200+ Cr
Invested
SEBI
Registered PMS