Derived Bollinger indicator

Bollinger Bands %B: turn price location into one testable number

Bollinger Bands %B measures price location inside or outside the bands. The lower band equals 0, the middle band equals 0.5, and the upper band equals 1 when the standard decimal formula is used.

Direct answer

%B = (price - lower band) / (upper band - lower band). Values above 1 place price above the upper band, while values below 0 place it below the lower band. That location is not a reversal forecast.

Starting values

Lower band

%B = 0

Middle band

%B = 0.5

Upper band

%B = 1

Above upper band

%B > 1

How I test the setup

  1. 1

    When I compare %B across SPY and QQQ, I use decimal values in both scripts. Some platforms display the same number as 0 to 100.

  2. 2

    I record the Bollinger length and multiplier with every %B threshold. A value of 0.8 depends on the bands that produced it.

  3. 3

    I test a cross and a level as different events. Closing above 0.8 is not the same rule as crossing 0.8 from below.

The %B formula

Subtract the lower band from the current price, then divide by the full distance between the upper and lower bands. If a platform multiplies the result by 100, the same reference points become 0, 50, and 100.

  • %B = (current price - lower band) / (upper band - lower band).
  • %B of 0.25 places price one quarter of the way up from the lower band.
  • %B of 1.10 places price above the upper band by one tenth of the band range.

Use %B as a precise condition, not a label

A chart can make near-band readings hard to compare. %B turns that position into a series that can be screened, alerted, and backtested. Define whether your rule uses a level, a crossover, consecutive closes, or a trend filter before testing it.

What %B does not tell you

A value above 1 does not automatically mean sell, and a value below 0 does not automatically mean buy. Strong trends can keep price near or beyond an outer band. Pair any re-entry rule with trend context, a stop condition, and realistic costs.

Common %B reference values

Price locationDecimal scalePercentage scale
Below lower bandLess than 0Less than 0%
At lower band00%
At middle band0.550%
At upper band1100%
Above upper bandGreater than 1Greater than 100%

Bollinger %B Pine Script prompt

This version exposes both the formula and the threshold direction.

Create a Pine Script v6 indicator for Bollinger Bands %B. Use close, length 20, and multiplier 2. Calculate percentB = (close - lowerBand) / (upperBand - lowerBand). Plot 0, 0.5, and 1 reference lines. Add bar-close alerts for crossing above 0.8, crossing below 0.2, crossing above 1, and crossing below 0. Keep each alert separate and guard against division by zero.
Generate the %B script

Pineify is an information tool, not investment advice. %B measures price location and does not guarantee a reversal, continuation, or return.

Common questions