Skip to content
Indicators 6 min read

Moving average envelope: calculation and chart use

How a moving average envelope sets bands a fixed percentage above and below an SMA, how to calculate and read it, and why sideways markets can mislead it.

Hypothetical daily candles with a 20-session SMA and dashed bands 5% above and below it, first in an advance and then in a range.RangeSMA 20Upper band +5%Lower band −5%
Hypothetical sessions, not market data. During the advance, closes push above the upper band several times; in the shaded range, the average levels off and closes reach both bands.

A moving average envelope draws two lines a fixed percentage above and below a moving average. Choose the percentage from the stock’s own typical swings, and remember that the band width never adapts to changing volatility.

What a moving average envelope is

A moving average envelope surrounds a moving average with two parallel lines set a fixed percentage away from it. The middle line is usually a simple moving average of closing prices; the upper line sits, for example, 5% above it and the lower line 5% below. The envelope frames how far price usually stretches from its average, so a close outside the band stands out as an unusually large deviation.

  • Inputs: closing prices.
  • Parameters: the period of the average and the band percentage; a 20-period SMA with 5% bands is one common default.
  • Units: all three lines are prices in dollars. The gap between them is constant in percent but grows in dollars as the average rises.
  • Cadence: on a daily chart a 20-period average covers 20 sessions; on a weekly chart it covers 20 weeks.

How to calculate the envelope

First compute the moving average, then multiply it by one plus and one minus the chosen percentage. The worked example uses a 10-session SMA with 3% bands to keep the tables short; the steps are the same for any period and width. The first average needs 10 closes, so the envelope starts at session 10.

Middle line = SMA(Close, n)
Upper band = Middle line × (1 + p / 100)
Lower band = Middle line × (1 − p / 100)
Distance from the average (%) = (Close / Middle line − 1) × 100
n
the number of sessions in the average
p
the band width in percent
Hypothetical closing prices
SessionClose ($)
140.10
239.80
340.30
440.60
540.20
639.90
740.40
840.80
940.50
1040.90
1141.70
1242.40
1343.10
1443.70
10-session SMA with 3% bands
SessionClose ($)SMA ($)Upper band ($)Lower band ($)Distance from SMA (%)Close position
1040.9040.3541.5639.14+1.36Between the bands
1141.7040.5141.7339.29+2.94Between the bands
1242.4040.7741.9939.55+4.00Above the upper band
1343.1041.0542.2839.82+4.99Above the upper band
1443.7041.3642.6040.12+5.66Above the upper band

At session 11 the close of $41.70 is still just under the upper band of $41.73. From session 12 on, the close sits more than 3% above its average, which is exactly what a close above the upper band means.

How to use the envelope on stock charts

An envelope is a yardstick for distance from the average, and its meaning changes with the market’s behavior. In a trend, closes beyond the outer band show how stretched the move has become, and price can ride along the upper band for long stretches. In a range, the bands can mark the edges of typical swings for as long as the range holds.

  1. Match the average to your horizon: 20 sessions follows swings of a few weeks, 50 sessions those of a few months.
  2. Set the width from the stock itself. One practical method is to widen or narrow the bands until most closes of the past year, say nine in ten, fall inside them.
  3. Read the slope of the middle line first. A rising average with closes near the upper band describes an advance; a flat average with closes alternating between the bands describes a range.
  4. Treat a close outside a band as a measurement of distance, then check the chart and the volume for what caused it.

A stock chart example

The hypothetical chart on this page draws daily candles with a 20-session SMA and bands 5% above and below it. During the advance on the left, closes push above the upper band several times while the lower band is never touched. In the shaded range on the right, the average levels off near $50 and closes reach both bands as price swings between about $47 and $53.

The same width means different things in the two phases. In the advance, a close above the upper band marks a stretch of an existing trend; in the range, closes near either band mark the edges of the swings.

Percentage envelopes compared with Bollinger Bands

Both tools draw bands around a moving average, but they size the bands differently. An envelope keeps a fixed percentage, while Bollinger Bands sit a number of standard deviations away, so they widen when closes become more dispersed and narrow when they settle. The choice is between a constant yardstick and one that adapts to recent volatility.

Envelope and Bollinger Bands side by side
FeatureMoving average envelopeBollinger Bands
Band distanceA fixed percentage of the averageA multiple of the standard deviation of recent closes
Reaction to volatilityNone; the width in percent stays constantBands widen and narrow with volatility
Common setting20-period SMA, 5%20-period SMA, 2 standard deviations
Useful forComparing distance from the average on a fixed scaleJudging distance relative to recent volatility

TradeClever’s Stock Charts can draw Bollinger Bands with a chosen period and number of deviations, alongside SMA overlays.

Limitations in sideways markets

Sideways markets expose the weaknesses of a fixed-width band. The average flattens, price crosses it repeatedly, and a band sized for one period of volatility can be too wide or too narrow for the next.

  • Bands that never get touched. If volatility contracts, price can swing for weeks without reaching bands sized for a livelier period.
  • Bands that get touched constantly. If volatility expands, closes outside the bands become routine and stop marking anything unusual.
  • Breakouts that look like extremes. The close that leaves a range often lands outside a band, so a reading that looked stretched inside the range may be the first session of a new trend.
  • Lag at the turns. The middle line is a moving average, so it keeps rising for a while after a top and keeps falling after a bottom, and the bands follow it.
  • No volume and no context. The envelope uses closing prices only and says nothing about why price moved.

Writing an envelope condition in CleverScan

TradeClever’s Stock Charts do not draw moving average envelopes. Because a band is a fixed distance from an SMA, though, the condition “close above the upper band” can be written as a CleverScan rule on a supported average. The rule below keeps stocks whose close is more than 2.5% above their 20-session SMA, the same test as a close above the upper band of a 20-session, 2.5% envelope.

securityType = "Stock" and close > sma20 * 1.025

The field distSma20Pct measures the same distance in percent, so distSma20Pct > 2.5 is an equivalent condition.

Read our data and methodology notes for calculation context. This guide explains research tools and observations. It does not recommend a trade or investment.

Follow your curiosity

One good question leads to another.

All guides
Make room for better research

Put your curiosity to work.

Build a scan with filters or CleverScan rules. Explore the results. Find your next idea.

Open a stock chart