Skip to content
Calculators

Bollinger BandsLive chartTopic guide

Bollinger Bands: formula, worked example and how to read them

A 20 period SMA with bands 2 standard deviations above and below it.

20, 2Volatility%b and bandwidthChecked 6 Dec 2026

Bollinger Bands chart example on a ranging currency pair with closes outside the upper and lower bands

Bollinger Bands are three lines drawn around price: a 20 period simple moving average in the middle, and an upper and lower band 2 standard deviations away from it. The bands widen when prices swing more and narrow when they calm down, so they show volatility and whether a close is high or low compared with recent prices.

This hub gives you the formula, a calculation you can check by hand, the two numbers traders derive from the bands, and why price outside a band is not a signal by itself. Each deeper topic has its own guide, linked below.

Quick read

  • Middle band

    20 period SMA of the close
  • Upper and lower bands

    SMA ± 2 x standard deviation of the same 20 closes
  • Defaults

    20, 2
  • %b

    (close - lower) / (upper - lower)
  • Bandwidth

    (upper - lower) / middle
  • Main weakness

    In a strong trend price can stay at one band for many bars

What are Bollinger Bands?

Picture a moving average with a flexible tube around it. The tube is wide when price has been jumping around and tight when it has been quiet. That tube is the Bollinger Bands indicator.

  • The middle band is the average close of the last 20 bars.
  • The upper band is the middle band plus two standard deviations.
  • The lower band is the middle band minus two standard deviations.

Standard deviation is a measure of how spread out the closes are. If all 20 closes were the same, it would be zero and the three lines would merge into one.

In the example below, a currency pair moved sideways between about 1.0738 and 1.0955. Price closed below the lower band at bars 24 and 26 and over the upper band on bars 38, 39, 41 and 59, yet it never left that 1.0738 to 1.0955 area. That is the usual look of a range: closes poke outside a band while the middle band stays fairly flat. Later on this page you will see the opposite picture, in a trend.

The Bollinger Bands formula

Middle band = SMA(20) = sum of the last 20 closes / 20
Standard deviation (SD) = square root of [ sum of (close - SMA)² / 20 ]
Upper band = SMA + 2 x SD
Lower band = SMA - 2 x SD

The bands use the population standard deviation, dividing by 20, not by 19. Some spreadsheet functions divide by n - 1 by default, which makes the bands slightly wider, so pick the population version if you want your numbers to match a charting app.

LineInputChanges when
MiddleLast 20 closesThe average price moves
UpperMiddle + 2 SDPrice moves or swings get bigger or smaller
LowerMiddle - 2 SDSame as upper, mirrored

How to calculate Bollinger Bands: a full example

Here are 20 closes from an example stock, oldest first: 101.2, 101.8, 102.5, 102.1, 103.0, 103.6, 103.2, 104.1, 104.8, 104.3, 105.0, 105.6, 105.1, 104.6, 105.3, 106.0, 106.4, 105.9, 106.7, 107.2.

  1. Middle band. The closes add up to 2088.4. Divided by 20 that is 104.42.
  2. Deviations. Subtract 104.42 from each close. The first is 101.2 - 104.42 = -3.22; the last is 107.2 - 104.42 = 2.78. The chart below shows all 20.
  3. Square and add. Square each deviation (for example -3.22² = 10.37) and add them: the total is 55.272.
  4. Variance. 55.272 / 20 = 2.7636.
  5. Standard deviation. The square root of 2.7636 is 1.6624.
  6. Bands. Upper = 104.42 + 2 x 1.6624 = 107.745. Lower = 104.42 - 3.3248 = 101.095.

The last close, 107.2, sits just under the upper band. Price has risen steadily, so the closes at both ends are far from the mean and they make the bands wide.

Columns of 20 closes minus their 104.42 average, step one of a Bollinger Bands standard deviation calculation
The oldest closes sit below the mean and the newest above it; their spread sets the band width.

%b and bandwidth: two numbers from the bands

Traders turn the bands into two simple readings.

%b tells you the position of the close within the bands. With the example numbers: (107.2 - 101.095) / (107.745 - 101.095) = 6.105 / 6.65 = 0.918. A %b of 1 means the close is on the upper band, 0 means on the lower band, 0.5 means on the middle. Above 1 or below 0 means outside the bands.

Bandwidth tells you how wide the bands are compared with price: 6.65 / 104.42 = 0.0637, or about 6.4 percent. Bandwidth is the reading behind the Bollinger Band squeeze: a low bandwidth compared with its own past means the market is unusually quiet.

How to read Bollinger Bands on a chart

  1. Check the width. Wide bands: an active, volatile market. Narrow bands: a quiet one.
  2. Check the slope of the middle band. Rising, falling or flat tells you the short term trend.
  3. See where closes cluster. In an uptrend most closes sit between the middle and upper band. In the walking example further down, 54 of 71 closes were above the middle band.
  4. Treat band touches as information. A close at the upper band says price is high compared with the last 20 bars. It does not say price will fall.
  5. Look for a second opinion. A level, a candle pattern at that level, or a momentum tool such as the RSI.

Try the bands on the interactive chart

The interactive chart above lets you switch the bands on and off, move the length and the standard deviation sliders, and draw a new example series. Two quick tests:

  • Drop the multiplier from 2 to 1 and count how many closes fall outside the bands. Then raise it to 3.
  • Press new example until you get a trend, then a range. Watch how differently price behaves at the bands in each.

The Bollinger Bands settings guide has a calculator where you can paste your own closes and get the bands for every bar.

Why a band touch is not a signal: walking the band

When a trend is strong, price may ride along one band for many bars. Traders call it walking the band. In the example below the stock rose from 121.22 to 143.20. It closed above the upper band at bar 29, then six times in a row from bar 50 to bar 55. After that run the close kept climbing, from 139.05 at bar 55 to 143.81 at bar 65.

Anyone who treated each upper band close as a reason to expect a fall would have been wrong again and again here. In a range, closes outside the bands tend to fade back; in a trend, they often mark strength.

Uptrend example where price closes above the upper Bollinger Band six bars in a row and keeps rising
Example chart: six closes in a row above the upper band at bars 50 to 55, then more gains.

Bollinger Bands entry and exit ideas, and where to read more

IdeaMarket it suitsGuide
Fade closes outside the bands back toward the middleSideways rangesBollinger Bands strategy
Follow a band walk, exit once price closes back past the middle bandStrong trendsBand walk and pullback rules
Wait for narrow bands, then a breakoutQuiet markets about to wake upBollinger Band squeeze
Choose length and widthAny time frameBollinger Bands settings

Since the middle band is a plain moving average, the simple moving average guide is useful background.

Limits of Bollinger Bands

  • The middle band is an SMA, so the whole indicator lags price.
  • Under a bell shaped distribution about 95 percent of values sit within 2 standard deviations. Prices are not bell shaped, and closes land outside the bands more often than that, especially in trends.
  • The bands show how far price is from its average, not where it is going.
Bands describe volatility; they do not predict direction. Forex and CFD positions held on margin can erase a deposit quickly, and in regulator surveys most retail accounts trading them end up losing. Rehearse any band method on old charts or in a demo account first. Read this as general education, not financial advice, and see Investor.gov's notes on technical analysis.

Questions traders ask

How do Bollinger Bands work?

They take a 20 period average and add and subtract two standard deviations of the same 20 closes. When prices swing more, the standard deviation grows and the bands widen. When prices calm down, the bands narrow.

What is the Bollinger Bands formula?

Middle band = 20 period SMA. Upper band = SMA + 2 x standard deviation. Lower band = SMA - 2 x standard deviation, using the population standard deviation of the same 20 closes.

How do you read Bollinger Bands for entry and exit?

Read the width first, then the slope of the middle band, then where closes sit. In ranges some traders look for closes outside a band to fade back; in trends a band walk often means strength. Any entry or exit idea needs testing on past charts.

What does it mean when price touches the upper band?

It means the close is high compared with the last 20 closes. In a range price often eases back to the 20 SMA; during a powerful trend it can keep walking along the band. It is not a sell signal by itself.

Do Bollinger Bands work on a stock chart and on forex?

Yes, the math is the same for any market with closing prices. A stock chart example and a currency pair example are both on this page. The bands behave differently in trends and ranges on every market.

Why do my band values differ from a spreadsheet?

The usual cause is the standard deviation type. Bollinger Bands use the population version, which divides by n. A sample standard deviation divides by n - 1 and gives slightly wider bands.

Bollinger Bands

Bands, squeezes and band strategies