Home / Guides / Bollinger Bands: formula, example and tested results

Bollinger Bands: formula, example and tested results

Bollinger Bands are a moving average with a band drawn a set number of standard deviations above and below it. The bands widen when price is volatile and narrow when it is quiet. The usual setting is a 20 period average with bands two standard deviations away.

A price line between an upper and a lower band with the middle line between them. The bands are wide on the left where price swings, narrow in the middle where it is quiet, and widen again on the right.

On AUDUSD, EURUSD, GBPUSD, XAUUSD and BTCUSD hourly bars (signal matrix v2), no Bollinger Bands rule held on data it had not seen after costs on any of the five markets, and the only ones that held at all, on XAUUSD and BTCUSD, held before costs only. In the older v1 test of the textbook rule (a close back inside the band), 5 of 30 cases averaged above zero after costs and 0 were beyond chance in the winning direction. The band touch showed no reliable edge. Past results, not a forecast.

Last updated 27 Nov 2026. Reviewed by the Custom Trading Platform education desk. Worked figures are sample arithmetic, shown in full. Test figures are results from our own tests on past data, with their cases, period and cost.

The short answer in four lines

  • The middle line is a simple moving average. The upper and lower bands sit two standard deviations away.
  • A touch of a band says price is far from its recent average, not that it must turn.
  • In strong trends price can ride the upper or lower band for a long time.
  • Band width shows how volatile the market has been, which is more useful than a touch.

The formula

  • Middle band equals the simple moving average of the last N closes, usually N is 20.
  • Standard deviation is taken over the same N closes.
  • Upper band equals the middle band plus K times the standard deviation, and lower band equals the middle band minus K times it. K is usually 2.
  • Percent B equals (close minus lower band) divided by (upper band minus lower band). It is 0 at the lower band, 1 at the upper band and 0.5 at the middle.
  • Bandwidth equals (upper band minus lower band) divided by the middle band.

Worked example (sample numbers)

A period of 5 and K of 2 are used so the working fits on a page. Five closes: 10, 11, 12, 11 and 13. The middle band is the average, 11.4. The deviations from it are minus 1.4, minus 0.4, 0.6, minus 0.4 and 1.6, and their squares add to 5.2. The variance is 5.2 divided by 5, which is 1.04, and the standard deviation is 1.0198. The upper band is 11.4 plus 2 times 1.0198, which is 13.44, and the lower band is 11.4 minus 2.0396, which is 9.36. Percent B at the close of 13 is (13 minus 9.36) divided by (13.44 minus 9.36), which is 0.892. Bandwidth is (13.44 minus 9.36) divided by 11.4, which is 0.358.

Window of 5 closesMiddleStandard deviationUpperLowerClosePercent BBandwidth
10, 11, 12, 11, 1311.41.019813.449.36130.8920.358
11, 12, 11, 13, 1111.60.813.210.0110.31250.276

Between the two windows the close fell back from 13 to 11, the bands narrowed (bandwidth from 0.358 to 0.276) and percent B dropped from 0.892 to 0.3125. Check your own closes with the volatility calculator.

How people read it

  • Band touches: a close above the upper band or below the lower band is read as price stretched. See the Bollinger Bands test.
  • The squeeze: narrow bands (low bandwidth) are read as a quiet market that may move soon.
  • Walking the band: in a trend price can stay at a band for many bars, so a touch alone is a weak reason to act.
  • With other tools: pair bands with a momentum reading such as the RSI guide.

Which Bollinger Bands rules held on data they had not seen (signal matrix v2)

Engine and question: signal matrix v2 asks which rules held on data they had not seen. Each rule was chosen on the first 70 of every 100 bars and counted on the rest, with a gap of 50 bars: from 2 January 2024 on AUDUSD, 12 February 2024 on EURUSD, 12 February 2024 on GBPUSD, 2 February 2024 on XAUUSD, 21 May 2024 on BTCUSD, hourly bars. A clear move is at least half the usual move over that many bars, and a smaller drift counts as flat. Costs are included: for AUDUSD, EURUSD, GBPUSD and XAUUSD the spread measured from real ticks at the hour the trade opens plus commission both ways, and for BTCUSD the median spread recorded on each bar with no commission, because there is no tick sample. Swap is excluded and real fills can be worse. The rules were chosen before the results, and every one is shown, including those that did not hold. These are results from past data and they do not predict what will happen.

RuleAUDUSDEURUSDGBPUSDXAUUSDBTCUSD
price crosses above the upper banddoes not holddoes not holddoes not holddoes not holddoes not hold
price crosses back below the upper banddoes not holddoes not holddoes not holddoes not holddoes not hold
price crosses below the lower banddoes not holddoes not holddoes not holddoes not holdholds before costs only
price crosses back above the lower banddoes not holddoes not holddoes not holddoes not holddoes not hold
price is above the upper banddoes not holddoes not holddoes not holddoes not holddoes not hold
price is below the lower banddoes not holddoes not holddoes not holddoes not holdholds before costs only
price crosses above the middle linedoes not holddoes not holddoes not holddoes not holddoes not hold
price crosses below the middle linedoes not holddoes not holddoes not holddoes not holddoes not hold
percent B in its lowest 5 of every 100 readingsdoes not holddoes not holddoes not holdholds before costs onlydoes not hold
percent B in its highest 5 of every 100 readingsdoes not holddoes not holddoes not holddoes not holddoes not hold
band width in its lowest 10 (a squeeze)does not holddoes not holddoes not holddoes not holddoes not hold
band width in its highest 10does not holddoes not holddoes not holddoes not holddoes not hold

The rules that held, with their clear move figures.

MarketRuleVerdictWayHorizon (bars)Clear move the rule's way, of every 100 unseen casesFlatClear move againstUnseen cases (n)Net per trade after costs
XAUUSDpercent B in its lowest 5 of every 100 readingsholds before costs onlyup149.411.838.83300.0181 of one percent
BTCUSDprice crosses below the lower bandholds before costs onlyup140.228.531.3520minus 0.0248 of one percent
BTCUSDprice is below the lower bandholds before costs onlyup140.727.831.5550minus 0.0201 of one percent

In the wider set of rules tested, only EURUSD held more often than luck alone would give, and the other markets held less often, so every rule that held is a hypothesis, not a finding.

What we tested: the textbook band re-entry (signal matrix v1)

Engine: signal matrix v1 (what happened after the textbook rule, over all history). The rule is a 20 period, 2 deviation band: when a close comes back inside the band after closing outside it, the trade is taken the opposite way to the breach, at the next open, and the move is measured 4, 12, 24, 50, 72 and 168 bars later. Events are counted only when they do not overlap. The unseen data check is the last 730 days against the earlier years, and the luck check is the beyond chance column. The v1 and v2 results answer different questions and are never added together.

MarketHorizon (bars)Cases (n)Average move before costsCostAverage move after costsShare ending ahead after costsEarlier years, after costsLast 730 days, after costsBeyond chance?
AUDUSD hourly43,389minus 0.031.17minus 1.247minus 1.01minus 1.97no (t minus 0.1)
AUDUSD hourly122,5190.291.17minus 0.8848.6minus 0.55minus 2.17no (t 0.48)
AUDUSD hourly241,7521.221.170.0549.70.1minus 0.07no (t 1.22)
AUDUSD hourly501,0080.761.17minus 0.4148.10.52minus 3.58no (t 0.4)
AUDUSD hourly727421.611.170.4449.9minus 0.345.29no (t 0.6)
AUDUSD hourly168345minus 6.771.17minus 7.9448.1minus 8.353.8no (t minus 1.15)
EURUSD hourly43,529minus 0.021.119minus 1.1447minus 0.77minus 2.64no (t minus 0.05)
EURUSD hourly122,536minus 0.141.119minus 1.2548.9minus 0.75minus 3.23no (t minus 0.2)
EURUSD hourly241,820minus 0.361.119minus 1.4849.4minus 0.68minus 4.73no (t minus 0.32)
EURUSD hourly501,0191.231.1190.1151.30.01minus 1.69no (t 0.54)
EURUSD hourly727598.221.1197.153.65.4213.51no (t 2.6)
EURUSD hourly168349minus 4.171.119minus 5.2950.1minus 2.51minus 8.64no (t minus 0.61)
GBPUSD hourly43,5120.311.241minus 0.9447.6minus 0.6minus 2.31no (t 0.57)
GBPUSD hourly122,501minus 0.151.241minus 1.3949.3minus 1.2minus 2.17no (t minus 0.16)
GBPUSD hourly241,8320.741.241minus 0.550.6minus 0.5minus 0.48no (t 0.48)
GBPUSD hourly501,019minus 1.781.241minus 3.0248.2minus 2.92minus 3.45no (t minus 0.55)
GBPUSD hourly72756minus 0.871.241minus 2.1148.8minus 2.14minus 3.93no (t minus 0.21)
GBPUSD hourly168348minus 6.351.241minus 7.645.7minus 19.725.56no (t minus 0.61)
XAUUSD hourly43,122minus 2.571.773minus 4.3448.6minus 2.91minus 10no (t minus 1.11)
XAUUSD hourly122,347minus 6.351.773minus 8.1248.7minus 5.86minus 17.04no (t minus 1.42)
XAUUSD hourly241,639minus 7.921.773minus 9.749.5minus 6.1minus 24.19no (t minus 0.97)
XAUUSD hourly50943minus 11.61.773minus 13.3749.3minus 8.53minus 32.56no (t minus 0.87)
XAUUSD hourly72694minus 9.61.773minus 11.3750.4minus 2.32minus 47.82no (t minus 0.44)
XAUUSD hourly168325minus 70.461.773minus 72.2345.815.25minus 454.45no (t minus 1.71)
BTCUSD hourly43,763minus 0.61minus 1.645.5minus 1.75minus 1.16no (t minus 2.45)
BTCUSD hourly122,774minus 0.581minus 1.5846.6minus 1.53minus 1.7no (t minus 1.22)
BTCUSD hourly241,941minus 0.61minus 1.650.6minus 1.81minus 0.99no (t minus 0.74)
BTCUSD hourly501,122minus 0.631minus 1.6350.6minus 1.63minus 1.48no (t minus 0.4)
BTCUSD hourly72830minus 3.81minus 4.850.5minus 5.89minus 1.24no (t minus 1.79)
BTCUSD hourly1683882.8811.8854.14.246.72no (t 0.55)

How to read the table. A pip is 0.0001 for AUDUSD, EURUSD and GBPUSD, 0.1 dollar for XAUUSD and 0.1 of one percent of the price for BTCUSD, so move sizes are not comparable across markets, only the sign and the share ending ahead are. Cost per round trip, in the same pips: AUDUSD 1.17, EURUSD 1.119, GBPUSD 1.241 (measured average spread plus 0.4 slippage plus 0.7 commission), XAUUSD 1.773 and BTCUSD 1.0 (assumptions, and a tick level spread read would refine them). Swap is not included. A row is beyond chance when its t statistic is larger than the 95th percentile of the best result found by shuffling event dates (AUDUSD 3.74, EURUSD 3.98, GBPUSD 3.75, XAUUSD 4.09, BTCUSD 3.85). The v1 tests used a flat cost per market and have not been checked independently by a second person.

What it cannot tell you

Bands describe how far price is from its recent average in units of recent volatility. They do not say which way price goes next. In a trend a band touch can repeat many times, and in a range it can fail often. Different settings (a 10 or 50 period, a K of 1.5 or 2.5) give different bands, and the tests used the usual 20 and 2.

Sources and method

Worked figures are sample arithmetic, shown in full, as of 27 Nov 2026, and each row was recomputed by a second method before it was kept. The v2 figures come from the signal matrix v2 requests of 27 Nov 2026 on hourly bars, and the v1 figures from the copy run of 26 Nov 2026. How we check numbers is on the methodology page, the people behind the site are on the about page, and corrections go through contact.

How we will test it

We will recompute both window rows in a second spreadsheet, repeat with a period of 20 and K of 2 on a second set of sample closes, recalculate the v2 and v1 tables, and repeat after the next data update. Last tested: not yet, results pending.

Questions people type

What are Bollinger Bands? A moving average with bands a set number of standard deviations above and below it, which widen and narrow with volatility.

How do you calculate Bollinger Bands? Take the simple average of the last 20 closes, add and subtract 2 times their standard deviation.

What do Bollinger Bands tell you? How far price is from its recent average, measured in recent volatility. They do not say which way price goes.

What are the best Bollinger Bands settings? The usual setting is a period of 20 and 2 deviations. In our tests the band touch rules did not hold on unseen data on four of five markets.

What is a Bollinger squeeze? Bands that have narrowed to a low width. It shows a quiet market. It does not say which way the move will go.

What is percent B? Where the close sits between the bands: 0 at the lower band, 1 at the upper.

Do Bollinger Bands work? In our tests a band touch alone did not show a reliable edge on five markets.

Related

Glossary, Bollinger Bands test, RSI guide, exponential moving average, volatility, volatility calculator, stop loss calculator, position size calculator, disclaimer.

Start free: create a free account to get the weekly note on tools and tests.

Education only. Nothing here is financial advice or a signal.

The exact rule and how we test it: Bollinger Bands test page.

More: all indicator guides, guides.

See also: Best RSI settings.