reference · Technical analysis

Bollinger Bands: Mean, Deviation and Width

Bollinger Bands place a volatility envelope around a moving average. The distance from the middle line depends on a chosen standard-deviation calculation, lookback and multiplier.

TradeCopier Editorial TeamPublished Updated
Price series inside upper and lower bands that narrow and widen around a moving average
Editorial illustration. Examples and calculations below state their own assumptions.

State the calculation convention

A common form uses a simple moving average as the middle line, with upper and lower bands a chosen number of standard deviations away. Fidelity describes the construction and adjustable parameters. A label such as 20, 2 usually means a 20-observation lookback and a two-deviation multiplier, but the price source and deviation convention still need checking.

Standard deviation describes dispersion around the mean. It does not count transactions or measure a gap from the previous close in the same way as ATR. Changing the band input from closes to typical prices, or changing the averaging method, changes the actual indicator being tested.

An original four-price calculation

Take hypothetical closing prices of 98, 100, 100 and 102. Their mean is 100. Squared deviations are 4, 0, 0 and 4, totaling 8. Using the population divisor of four gives variance 2 and standard deviation approximately 1.4142.

With a multiplier of two, the upper band is 102.8284 and the lower band is 97.1716. Band width is approximately 5.6568 price units. Dividing that width by the middle line and multiplying by 100 produces a relative width of approximately 5.6568%.

Using the sample divisor of three instead produces deviation approximately 1.6330 and wider bands at about 103.2660 and 96.7340. This is not a rounding disagreement. It is a different statistical convention. A spreadsheet and chart should be compared only after their input and denominator choices match.

Bollinger %B measures position, not band width

Bollinger %B expresses a selected price's position relative to the two bands. This page uses the decimal fraction %B = (price − lower band) / (upper band − lower band). Multiply that fraction by 100 for a percentage display. Fidelity presents the percentage convention; compare the displayed scale before comparing thresholds between tools.

At the lower band the fraction is 0, at the midpoint it is 0.5, and at the upper band it is 1. Their percentage displays are 0%, 50% and 100%. A decimal reading of 0.85 therefore means 85% of the distance from lower to upper; it does not mean 0.85%, an 85% chance of profit, or a return of 85%. BandWidth instead describes the distance between bands relative to the middle line.

Using the original population bands above and the last close of 102, the numerator is approximately 4.828427 and the denominator 5.656854. The fraction is 0.8535533906, displayed as 85.35533906%. Keep the unrounded bands in the calculation. With the sample-deviation bands and the same close, the fraction changes to 0.8061862178, or 80.61862178%. Changing the denominator convention changes the location reading even though price has not changed.

Outside the bands is a valid result

Hold the population bands fixed at their original values. A separately tested price of 96 gives −0.2071067812, or −20.71067812%; a price of 104 gives 1.2071067812, or 120.71067812%. These are alternative prices compared against a frozen window, not extra observations inserted into that window. Negative and above-one values retain information about distance outside the envelope. Clipping them to zero or one would discard that information.

Original four-price population bands: price 102 lies at decimal percent B 0.853553; price 104 is outside frozen bands but inside bands recomputed with the new observation
Original synthetic arithmetic. The top price axis uses fixed population bands; the lower comparison explicitly changes the input window. Rounded labels are for reading, not intermediate calculation.

A rolling window changes the question

Now let 104 become the next completed close and roll the four-observation window. Drop 98, retain 100, 100 and 102, then append 104. The new mean is 101.5. Squared deviations sum to 11, so population variance is 2.75 and deviation is approximately 1.6583123952. With the same multiplier of two, the new lower and upper bands are 98.1833752096 and 104.8166247904. Price 104 now has a fraction of 0.8768891807, or 87.68891807%.

The frozen result above one and the rolled result below one are both correct for their stated inputs. One compares a new price with the previous window; the other includes that price in the window. A rule tested against yesterday's final bands cannot silently use today's final bands instead. Record the observation timestamp and which window was available at the decision, particularly when comparing intrabar readings with stored closing values.

Zero-width and missing-input cases

For four identical closes of 100, the mean is 100 and deviation is zero. Both bands equal 100. At price 100 the expression becomes 0/0, which is undefined, not a neutral 0.5. A different comparison price still divides by zero. Report an unavailable value with a zero-width reason; do not manufacture a midpoint or carry forward a previous result without explicitly labeling that separate policy.

Missing prices, an incomplete required window or non-finite values also need an unavailable state. A very small positive width can magnify small price differences; avoid rounding bands to identical displayed values before calculating. Keep the selected input precision, and document any numerical tolerance used to classify a width as effectively zero.

Download the reproducible example CSV. Each row names its complete window, population or sample divisor, multiplier, comparison price, bands and both display scales. Boundary rows use the calculated band values themselves. The zero-width row leaves both outputs empty and states why. These are synthetic fixtures for checking arithmetic, not observed trades or evidence of a profitable rule.

Do not infer an automatic probability

A two-deviation envelope around recent prices is not automatically a 95% prediction interval for the next price. The familiar normal-distribution coverage statement requires assumptions that a rolling series of dependent market prices does not establish. The mean and deviation also change as observations enter and leave the window.

John Bollinger’s own rules distinguish a band touch from a standalone trading signal. Likewise, touching the upper band does not mean price must fall. A sustained move can repeatedly place price near or beyond a changing band. A narrow envelope describes recent compression under the selected calculation; it does not identify which direction a later expansion will take.

Make any proposed rule observable

If a rule refers to a band touch, specify whether the high crossing is sufficient or the close must finish outside. Decide whether the band is frozen at the previous close or recomputed during the current bar. Otherwise, the threshold can move while price is being tested against it, making a historical example difficult to reproduce.

Compare Keltner Channels, whose range-based width answers a different question. Review standard-deviation conventions before comparing values across software. Then use the backtesting protocol to evaluate a precise rule with trading costs, rather than assigning a reversal probability to an attractive envelope.

Test compression and expansion as a complete rule

John Bollinger identifies BandWidth as one way to find a squeeze, while warning that a band tag alone is not a trading signal. Narrow bands describe the selected closing-price window; they do not supply a direction or a forecast. The invented sequence below turns a contraction-to-expansion idea into a checkable rule and deliberately includes a veto and a loss.

Use four completed closes per band so every row can be recomputed by hand; this is not a recommended live lookback. At bar t, the middle band is the four-close simple mean, deviation is the square root of the mean of four squared deviations (population divisor four), and upper/lower bands are the mean plus/minus two deviations. BandWidth is 100 × (upper − lower) / middle, in percent. Require a finite positive middle and a complete four-close window; otherwise mark the bar unavailable.

Freeze the decision gates before reading the example

  1. Compression: the previous completed bar's BandWidth is at most 0.5%.
  2. Expansion: the just-completed bar's BandWidth is at least 1.0% and strictly greater than the previous width.
  3. Breakout: the just-completed close is strictly above the previous upper band for a possible long, or strictly below the previous lower band for a possible short. Bands recomputed with that close do not replace the frozen threshold.
  4. Separate direction filter: the previous four-close middle band is strictly above its own preceding value for a long, or strictly below it for a short. A flat slope, a contrary slope, a close equal to the threshold, or any missing gate means no trade.
  5. Timing and costs: decide after bar t closes, enter one synthetic unit only at bar t+1's open, and exit at that same bar's close. Subtract 0.2 price units per unit for an assumed complete round trip, including spread, slippage and commissions. If the next bar is absent, the signal is pending and cannot be scored.

The 0.5% and 1.0% levels and one-bar holding period are illustrative fixed choices, not optimized thresholds or a claim that this rule is useful. Direction comes from the prior moving-average slope, a separate rule derived from the same prices rather than independent confirmation. Current BandWidth uses the completed signal close, so no order is placed at that already-known close. The frozen prior bands are available before the signal bar begins.

Read the chronological synthetic ledger

At bar 9, prior BandWidth is 0.282278% and current width is 1.332247%. The close of 101 is above the frozen prior upper band of 100.341421, while the prior middle band rose from 100.15 to 100.20. All four gates pass for a long. The close remains below the new upper band of 101.093954, illustrating why silently swapping in current bands would change the result. Entry at bar 10's open of 101.1 and exit at its close of 101.4 give +0.3 gross and +0.1 after the assumed 0.2 cost, per unit.

At bar 14, the close of 100.5 falls below the frozen lower band of 101.338397 and width expands from 0.170772% to 1.605541%. The prior middle band still rose from 101.325 to 101.425. That is a direction veto, not a short trade to count as a winner or loser. At bar 20, the close of 99 falls below its frozen lower band of 99.726393; width expands from 0.447437% to 1.589464%, and the prior middle band fell from 100.05 to 99.95. The short enters at bar 21's open of 98.9, but its exit at 99.5 yields −0.6 gross and −0.8 after costs, per unit. Expansion did not prevent a reversal.

Synthetic Bollinger test: bar 9 passes a long and gains 0.1 price units after assumed costs; bar 14 is vetoed by the prior average direction; bar 20 passes a short but loses 0.8 units after costs
Original synthetic decision ledger. Each breakout compares the completed close with the previous bar's frozen bands; a matched next-open entry is scored only when a next bar exists. Scroll the diagram horizontally on a narrow screen.

Separate an illustrative split from real evidence

Download the 22-bar CSV ledger. Bars 1–8 provide construction and warm-up observations; bars 9–22 are labeled the illustrative evaluation segment. The rule is stated before that segment here, but the entire sequence was invented to expose the mechanics. It is not an independently held-out market sample, a measured backtest, a TradeCopier signal-generation feature, or evidence of a profitable strategy. The two executed synthetic decisions net −0.7 price units per unit together; neither that number nor the one winning example estimates future results.

For actual evaluation, choose the instrument, timeframe, timestamp convention, input prices, population-versus-sample divisor, width thresholds, direction filter, entry/exit policy and cost model on an earlier development interval. Lock them before opening a later untouched interval, and retain every accepted, rejected, unfilled and losing case. MetaQuotes documents a forward testing split and execution-model settings in the MetaTrader 5 Strategy Tester; its simplified pips mode omits commission and swap, so it cannot validate a cost-sensitive result on its own. If many settings are tried and the best is chosen after seeing the later interval, that interval is no longer untouched. Review out-of-sample testing and selection bias before interpreting any apparent edge.

Real fills can differ from these invented bar opens and closes because of gaps, spread changes, slippage, venue rules or rejected orders. Keep the source indicator, strategy decision and copying/execution records separate. A copied order's outcome cannot be inferred from a chart band alone.

Questions and answers

What is the Bollinger percent B formula?

On a decimal scale, %B = (price − lower band) / (upper band − lower band). Multiply by 100 for a percentage display. Both require a nonzero band width.

Does percent B of 0.85 mean 0.85 percent?

No. A decimal fraction of 0.85 corresponds to an 85% display: the price is 85% of the way from the lower band to the upper band. Check which scale your software uses.

Can Bollinger percent B be negative or greater than one?

Yes. On the decimal scale, a price below the lower band produces a negative value and a price above the upper band produces a value above one. These are valid locations, not probabilities.

What happens when both Bollinger Bands are equal?

The formula divides by zero and is undefined. Report the value as unavailable with a zero-width reason instead of assigning zero or 0.5.

Why does percent B change when I include the latest close?

Including the latest close and dropping the oldest observation changes the rolling mean and deviation. Comparing against frozen previous bands and recomputing bands with the new close answer different questions.

Is percent B the same as Bollinger BandWidth?

No. Percent B measures price location relative to the lower and upper bands. Relative BandWidth divides the distance between the bands by the middle line, often with a multiplication by 100.

Why are my spreadsheet bands wider?

Check whether it uses sample rather than population deviation, then compare price input, lookback, missing observations and averaging method. These choices can also change percent B.

Are prices guaranteed to stay inside two-deviation bands?

No. The bands describe a moving historical window and do not automatically form a valid future prediction interval. A band touch or extreme percent B value alone does not prove a reversal or profitable strategy.

Does a Bollinger squeeze predict breakout direction?

No. Narrow BandWidth describes recent price dispersion under a selected calculation. Direction, entry timing, costs and failure handling need separate rules and evaluation.

Should a breakout use the previous or current Bollinger Bands?

State the rule explicitly. The synthetic test here compares a completed close with bands frozen from the previous completed bar; recomputing the bands with that close changes the threshold.

Does the synthetic Bollinger test prove the rule works?

No. The bars were invented to make the decisions auditable, including a veto and a losing short. Only a genuinely untouched later market sample with fixed rules and realistic costs can evaluate a trading hypothesis.

Sources and further checks

Use the current source for your exact instrument, account and platform. Referencing a general specification does not establish support for every TradeCopier workflow.

  1. Fidelity: Bollinger Bands · Checked September 22, 2026
  2. Fidelity: Percent B (%B) · Checked September 22, 2026
  3. John Bollinger: Bollinger Bands Rules · Checked September 23, 2026
  4. MetaQuotes: MetaTrader 5 Strategy Testing · Checked September 23, 2026

Found an error? Send a correction with this page's address and a primary source. See our editorial standards for how we handle examples, claims and revisions.

Check the product workflow

Use these pages to check TradeCopier settings and connection requirements for your own setup.

Browse all resourcesCurrent resource: /learn/bollinger-bands

Start Copying Smarter Today

Connect supported accounts with configurable sizing, risk controls, activity logs, and alerts.

Get Started Free