全職奶爸

Bollinger Bands: Formula, TradingView Settings and Squeeze Examples

Bollinger Bands: formula, settings and squeeze examples

Bollinger Bands show how price sits relative to a moving average and its recent dispersion. The common starting point is a 20-period simple moving average, with an upper and lower band two standard deviations away. The bands widen as dispersion increases and narrow as it decreases.

A touch of the upper band describes a relatively high price within that calculation. It does not automatically tell you to sell. Price can keep walking along the upper band in an uptrend or the lower band in a downtrend. The useful question is whether you are seeing a range, a volatility breakout, or an established trend.

This guide works through the formula, the actual TradingView inputs, and the difference between a squeeze and a directional entry. The arithmetic examples use hypothetical prices; the market chart is a historical illustration of how the bands behave.

Bollinger Bands formula: what 20 and 2 mean

For the standard SMA version, calculate the average of the last 20 selected prices. Then calculate their standard deviation over that same window. The upper band is the average plus two standard deviations; the lower band is the average minus two standard deviations.

Basis = SMA of the selected price over N periods.
Upper band = Basis + multiplier × standard deviation.
Lower band = Basis − multiplier × standard deviation.

On a five-minute chart, 20 periods means 20 five-minute bars. On a daily chart, it means 20 daily bars. Twenty does not automatically mean 20 days when you change chart timeframes. A different source, such as a bar's typical price, also changes the series going into the calculation.

For a reproducible example, take 20 closes alternating between 98 and 102. Their mean is 100. Using population standard deviation for this example, the squared deviations are all 4, the variance is 4, and the standard deviation is 2. With a multiplier of 2, the upper band is 104 and the lower band is 96.

The last close, 102, is inside those bands. Now replace that final 102 with 110. The new average is 100.4, the variance is 8.64, and the standard deviation is approximately 2.9394. The upper band moves to approximately 106.2788, while the lower band moves to approximately 94.5212.

The close at 110 is still above the recalculated upper band. The calculation adapts to the new observation; it does not create a wall that the price must stay inside. When checking your own spreadsheet or code, match the platform's source, lookback, averaging method and standard-deviation convention. Using a sample divisor of N−1 changes the result from the population calculation used here.

Two standard deviations do not guarantee 95% containment

The familiar 95% figure belongs to a normal-distribution model under its assumptions. A rolling band around a financial price series is not a promise that 95% of future closes will remain inside it. Prices are dependent over time, distributions can have heavy tails, and both the average and dispersion change as the window rolls.

John Bollinger's official rules explicitly caution against making statistical assumptions from the standard-deviation calculation. Treat the band as a relative reference. Do not convert an outside close into a claimed reversal probability or a guaranteed return to the middle.

That distinction changes the trade decision. If price closes above the upper band, you have an observation to evaluate against the setup's trend, range and invalidation rules. You do not have a statistical entitlement to short it. An unusually strong move can remain unusually strong for longer than a countertrend position can tolerate.

TradingView Bollinger Bands settings: a clear baseline

Open the chart's indicator search, type Bollinger Bands, and choose the built-in indicator under Technicals. Open its settings using the gear beside the indicator name. Community scripts and strategies can use different calculations or add entry rules, so confirm which indicator you have added.

TradingView Bollinger Bands Inputs showing Length 20, SMA, Close, StdDev 2, Offset 0 and chart timeframe
The built-in Inputs provide one baseline you can record and repeat.
InputBaselineWhat to verify
Length2020 bars of the indicator's selected timeframe
Basis MA TypeSMAThe averaging method used for the basis
SourceCloseThe price series used in the calculation
StdDev2The distance multiplier, not a success probability
Offset0No forward or backward displacement of the plot
TimeframeChartUse the current chart timeframe for this baseline
Wait for timeframe closesRelevant when using a higher timeframeWhether confirmed higher-timeframe values wait for that bar to finish

Keep these settings unchanged while learning to distinguish market states. Length, multiplier and source each alter the output. Changing several inputs after an unsuccessful trade makes it harder to determine which rule you actually tested.

A shorter length responds to a smaller recent sample; a larger multiplier places the outer bands further from the basis for the same calculated dispersion. Those changes alter the observations your entry rule will encounter. They do not establish that the resulting strategy has a higher expected return.

Timeframe and session settings matter too. A chart that includes overnight bars uses a different sequence from one that includes only regular-session bars. Compare the same symbol, feed and session before deciding that two platforms disagree. The TradingView indicators guide covers selecting and organizing a chart setup without treating every added line as another trade instruction.

%B measures position; BandWidth measures width

%B = (price − lower band) ÷ (upper band − lower band). With distinct bands, a value of 0 places price at the lower band, 0.5 at the basis of a symmetric band, and 1 at the upper band. Values above 1 or below 0 describe prices outside the envelope.

In the alternating-price example, price 102 with bands at 96 and 104 produces %B of 0.75: (102−96) ÷ (104−96). That value describes location. It is not a 75% chance of a rising market, and it does not mean 75% of the trade's potential profit has been captured.

BandWidth, expressed as a percentage = (upper band − lower band) ÷ basis × 100. The same example has an 8% BandWidth: (104−96) ÷ 100 × 100. A platform displaying the unmultiplied ratio would show 0.08 instead. Keep the unit beside the value when comparing charts or scanning results.

Price position and band width are different measurementsHypothetical bands lower96,basis100,upper104andclose102. PercentB=(102-96)/(104-96)=0.75;BandWidth=(104-96)/100times100=8percent. Neither isprobability.Price position and band width are different measurementsHYPOTHETICAL · Basis 100 · Lower 96 · Upper 104 · Price 102Lower 96Basis 100Upper 104Price 102%B = (102 − 96) ÷ (104 − 96) = 0.75BandWidth = (104 − 96) ÷ 100 × 100 = 8%Location and relative width; neither value predicts the next direction.

A squeeze concerns a small width relative to that market's own history. %B concerns where price sits within the current envelope. A low BandWidth does not require %B to be near zero, and a high %B does not by itself establish a wide band.

Handle degenerate cases explicitly. If the two bands are identical, the denominator in %B is zero and the ratio is undefined. It does not become a neutral 0.5 automatically. A zero basis also prevents the usual BandWidth percentage calculation; follow the platform's handling rather than manufacturing a valid-looking value.

A Bollinger Band squeeze identifies compression, not direction

A squeeze describes relatively narrow bands. It can help identify a period worth watching for expansion, but it does not select the direction of the next move or guarantee when expansion will arrive. Quiet conditions can persist, and the first move out of a range can fail.

To define a testable breakout setup, mark the consolidation's price high and low while the bands are narrow. Specify whether a close outside that price range is required, whether width must begin increasing, and which condition invalidates the entry. These are additional strategy rules; the bands do not supply them automatically.

Keep a separate failed-breakout condition. For example, a strategy might require the next completed bar to hold outside the range and abandon the setup if it closes back inside. That rule can miss fast moves and will not eliminate losing trades. Its value is that it defines what you will record and test.

Compare BandWidth with the same instrument, timeframe and session history. A daily stock chart and an intraday futures chart do not need the same numerical threshold. If you use a percentile or a rolling low as the definition of narrow, write down the lookback and calculate it from information available at that moment.

A longer compression does not authorize a larger position. Position size still depends on the entry-to-invalidation distance, contract value, costs and available risk. When expansion produces a larger confirmation bar, keeping the old quantity can increase dollar risk even if the entry rule appears unchanged.

Why prices can keep walking the upper or lower band

In an established uptrend, price may repeatedly reach the upper band while pullbacks remain above the basis. The basis and the outer bands can rise together. The upper band is recalculated as prices change, so repeated touches do not exhaust a fixed supply of upward movement.

A downtrend can produce the opposite sequence: repeated lower-band contacts, rebounds that struggle around the basis, and a falling envelope. Buying each lower-band touch treats a trend as though it were a horizontal trading range.

Historical July 2026 chart showing Bollinger Band contraction, expansion and price walking a declining lower band
Historical illustration: the right side keeps following the declining lower band. Open the chart at full size to inspect the sequence.

Read the sequence rather than one contact. Has the basis flattened? Has price stopped closing near the same outer band? Has it reclaimed a prior swing level? Such changes can describe weakening continuation conditions, but none supplies a guaranteed turning point.

If your strategy fades an outer band, define the range conditions that must remain present. If it trades continuation, define the pullback and invalidation instead. Switching from a failed fade to a continuation story while retaining the original trade changes the strategy after entry.

A changing window can narrow the bands without a new breakout

Standard rolling calculations remove an old observation whenever a new one enters. A dramatic width change can therefore reflect what left the sample as well as what just happened in the market.

Consider a hypothetical 20-close window whose oldest value is 120 and whose remaining 19 values are all 100. The mean is 101 and the population standard deviation is approximately 4.3589. With two deviations, the bands sit near 109.7178 and 92.2822.

Now the next close is also 100. The oldest 120 leaves, producing 20 identical closes at 100. The standard deviation becomes zero and both bands equal 100. Width collapses even though the newest price did not move relative to the preceding close.

A rolling window can narrow without a new price moveA hypothetical20closewindow hasoldest120andnineteen100values. Basis101,populationSD4.3589,upper109.7178,lower92.2822. Thennew100removesoldest120;all20values100,basis100,SD0,bands100and%Bundefined.A rolling window can narrow without a new price moveHYPOTHETICAL · 20 closes · SMA · Population SD · Multiplier 2Before: oldest 120 + nineteen closes at 100Basis 101 · SD 4.3589Upper 109.7178 · Lower 92.2822Next close 100 removes the oldest 120Twenty closes at 100 → SD 0 → both bands at 100BandWidth 0% · %B undefined (zero denominator)The newest close is unchanged; the old outlier left the calculation.

This is a deliberately simplified arithmetic example. It demonstrates why a band contraction alone cannot establish that sellers or buyers have finished. Inspect the window, price structure and activity instead of assigning every width change a directional narrative.

W-bottoms and M-tops: compare price with its own band

A lower price low can occur with less relative weakness. A schematic W-bottom might have a first close below the lower band, a rebound toward the basis, and a second, slightly lower price low that holds above its newly calculated lower band. The second low is compared with the band at that time, not with a frozen copy of the first band.

The rebound's intervening resistance still matters. A subsequent break can provide a defined confirmation rule; the relative-band difference alone is a warning to investigate. Record whether your pattern uses closes or intrabar extremes so its identification does not change from chart to chart.

An M-top reverses the relationship. Price may make a new high while failing to reach its current upper band, then break the intervening support. That relative non-confirmation can coexist with further gains before any support break occurs. A warning and a confirmed entry are separate events.

These patterns help organize observations, rather than guaranteeing a particular win rate. If you add another filter, identify what information it contributes and measure the resulting sample. A more elaborate checklist can reduce the number of trades without improving their net outcome.

RSI, MACD, ATR and Keltner Channels answer different questions

Bollinger Bands describe price location relative to an average and recent dispersion. RSI measures the balance of recent upward and downward price changes. Price touching an upper band and RSI reaching a high reading can both occur during a strong trend; combining the two does not force a reversal.

MACD describes relationships between moving averages and its signal calculation. It can supply a momentum or trend condition for a defined setup. Because both tools derive from price, treat their agreement as a rule to evaluate rather than independent evidence that doubles the odds.

ATR works from true ranges, including comparisons with the previous close. Bollinger width works from dispersion of the selected price series. A gap or the expiry of an old observation can therefore affect the two measures differently.

Common modern Keltner Channels use an average with an ATR-based distance. Keep their exact definition and settings visible when comparing them with Bollinger Bands. Declaring one channel universally smoother or better skips the effects of its averaging method, length and multiplier. The Keltner Channels comparison shows why narrower Bollinger width alone does not establish a squeeze when the two channel centers differ.

Plan trade risk separately from the moving band

An outer band can move further from your entry as dispersion increases. Using that moving line as an unrestricted stop can enlarge a losing trade's risk. Choose a price-based invalidation and an exit rule that explicitly states whether a protective stop may tighten, remain fixed, or otherwise change.

Translate the distance into money before choosing quantity. A 20-point stop on one MNQ represents $40 before costs; the same point distance on one NQ represents $400. Fees and adverse execution allowances add to the planning amount. The position sizing calculator guide explains whole-contract rounding and a zero result when the minimum quantity exceeds the budget.

Breakout conditions can also produce an entry fill different from the price observed when the signal completed. If accounts are copied or orders arrive at different times, do not assume every account receives the same entry. Measure the actual executions under your platform's rules and include the differences in the trade record.

For a futures prop firm account, check remaining drawdown capacity, product limits and current account-stage rules separately. A narrow channel is a chart observation, while the account threshold is an operational constraint. Neither the headline account size nor the maximum contract allowance sets an appropriate trade risk.

Compare HDP discounts

Lucid 30% · Tradeify 30% · TPT 50%.

See current offers ↗

Eligible partner plans only.

How to test a Bollinger Bands strategy without changing the rules midstream

Write the market, session, timeframe, indicator source and settings beside the entry rule. Define the stop, target or trailing exit independently. State whether decisions use completed bars and whether a signal can be acted on at the close or only at the next executable price.

Keep the development sample separate from later validation. If you select a multiplier after seeing every trade in the sample, that result includes the selection process. Test the selected version on subsequent data under the same execution and fee assumptions.

Record losing squeezes, trend days when a fade failed, and quiet sessions with no entry. Review average net win, average net loss, drawdown and trade count alongside win rate. A strategy with a high win rate can still lose money if occasional losses and costs exceed its smaller gains.

For intraday testing, keep the spread, contract multiplier and realistic order timing consistent. A plotted band crossing is not proof of an accepted broker order or a fill. Examine enough trades to see whether the indicator changes a useful decision, then retain the version you can describe and reproduce.

Bollinger Bands FAQ

What are Bollinger Bands?

They are a moving-average basis with upper and lower bands set using recent price standard deviation. The common baseline is a 20-period SMA with two standard deviations on each side.

What do 20 and 2 mean in Bollinger Bands?

Twenty is the lookback in bars of the chosen indicator timeframe. Two is the standard-deviation multiplier. Twenty means 20 daily bars only when the calculation uses a daily timeframe.

What is the Bollinger Bands formula?

The basis is the selected moving average. For the standard SMA version, add multiplier times standard deviation to obtain the upper band and subtract it to obtain the lower band, using the same lookback.

Does touching the upper band mean sell?

A touch describes relative price location. It can occur during an ongoing uptrend, a range, or a failed breakout. Use a separately defined setup and invalidation rather than treating the touch as an automatic order.

Does touching the lower band mean buy?

A strong downtrend can keep walking the lower band. Evaluate trend, range and confirmation conditions before applying a mean-reversion entry rule.

What is a Bollinger Band squeeze?

It is a period of relatively narrow bands. It identifies reduced dispersion compared with the selected history, while the direction and timing of any following move remain unknown.

What are the best Bollinger Bands settings?

There is no universal best combination. Start with a recorded baseline such as 20 and 2, then test any change for the chosen market, session, timeframe and execution costs on separate validation data.

Which settings work best on a one-minute or five-minute chart?

Chart speed alone does not establish a profitable parameter set. One-minute and five-minute data create different samples and trading costs relative to movement. Specify the setup and compare its complete results instead of relying on a claimed best preset.

What is the difference between %B and BandWidth?

%B measures price position relative to the bands. BandWidth measures their separation normalized by the basis. Neither value is a predicted probability.

Can %B go above 1 or below 0?

Yes. Above 1 places price above the upper band; below 0 places it below the lower band. If the bands coincide, the usual %B calculation has a zero denominator and is undefined.

Do two-standard-deviation bands contain 95% of future prices?

No fixed future containment rate is guaranteed. Financial price series and rolling calculations do not satisfy the assumptions needed to turn the familiar normal-distribution figure into that trading claim.

Do Bollinger Bands repaint?

Values on the current bar change as its source changes. Higher-timeframe values can also remain unconfirmed until that bar closes. Distinguish those updates from later data revisions and use completed-bar rules consistently.

How do I add Bollinger Bands in TradingView?

Search for Bollinger Bands in the indicator menu and select the built-in Technicals result. A clear baseline is Length 20, SMA, Close, StdDev 2, Offset 0, and the chart timeframe.

What is the success rate of a Bollinger Bands strategy?

The indicator has no universal success rate. Results belong to a specific entry, exit, market, sample and cost model. Measure net expectancy and drawdown alongside win rate.