How it works
Percent b converts the position of price within the Bollinger envelope into a single normalised number. One means the close is exactly on the upper band, zero means it is on the lower band, and 0.5 means it is sitting on the moving average. Values above one and below zero are perfectly legal and mean the close finished outside the envelope. That rescaling turns a visual judgement into something a rule can be written against and something that can be compared across instruments.
The value of the transformation is that it folds two pieces of information into one series. Raw distance from the mean is meaningless without knowing current volatility, and current volatility is meaningless without knowing where price sits. Percent b holds both: the same 0.95 reading means the market is near the top of its recent distribution whether the envelope is two percent wide or twenty percent wide. That makes it a natural input for screening across a universe, which is how quantitative users most often deploy it.
Traders read it in three modes. As a stretch gauge, sustained readings above one identify a band walk and therefore a strong trend, while a first excursion below zero after a long uptrend is a genuine character change. As a divergence tool it is better behaved than raw price because it already accounts for volatility, so a lower %b high against a higher price high says the second push was weaker relative to conditions. And as a filter it composes cleanly with momentum work, since a rule such as %b below 0.2 while a longer-term average still rises isolates pullbacks inside trends without hand-tuned price levels.
It shares a family resemblance with the stochastic oscillator, which also locates price inside a recent range, but the reference differs in an important way. The stochastic scales against the raw highest high and lowest low, so a single spike defines the boundary for the whole lookback. Percent b scales against a statistical dispersion measure centred on the mean, which reacts to the whole distribution rather than to two extreme prints. In quiet markets the two agree closely; around shocks they diverge sharply, and %b is usually the more informative of the pair.
Calculation
The arithmetic in words, in the order it happens.
Take the standard Bollinger set: a 20-period simple moving average as the middle band, with upper and lower bands 2 standard deviations of the same 20 closes above and below it. Percent b is the close minus the lower band, divided by the upper band minus the lower band. Equivalently it is 0.5 plus the distance of the close from the average divided by twice K times the standard deviation. The result is unbounded: it exceeds 1 whenever the close is above the upper band and falls below 0 whenever the close is beneath the lower band.
Source
An AlgoBeamScript implementation of the formula above, written by us from the arithmetic so the code and the calculation agree line for line.
Runs unchanged on the platform and in the AlgoBeamTS runtime. The language reference is in the documentation.
Inputs
Defaults are the values most charting packages ship with. They are conventions, not optimal settings — the right length depends on your instrument and your holding period.
| Input | Default | What it changes |
|---|---|---|
| Length | 20 | Bars in the underlying average and deviation. Shorter windows produce a fast oscillator that frequently visits the extremes; longer windows make readings outside the zero-to-one range genuinely rare. |
| Standard deviations | 2 | Sets how far the boundaries sit from the mean. A smaller multiplier compresses the scale so the series spends more time outside the zero-to-one range; a larger one keeps it almost permanently inside. |
| Source | Close | The price compared against the envelope. Using the high or the low instead of the close answers a different question, namely whether the bar touched the band rather than whether it finished beyond it. |
How to read it
What practitioners take from the plot. Read these as descriptions of market state, not as entry signals.
- Above 1.0 on consecutive bars
- A band walk. Momentum is strong enough that closes keep exceeding the envelope, which is a continuation state rather than an exhaustion one.
- Crossing back below 1.0 after a walk
- The first close back inside the envelope after a sustained walk. Often the earliest sign that the impulse is done, though it commonly resolves as a pause rather than a reversal.
- Falling to roughly 0.2 while the trend structure holds
- A pullback into the lower half of the envelope inside an uptrend, the classic buy-the-dip location for envelope-based systems.
- Lower high in %b against a higher high in price
- The newer push is less extreme relative to current volatility. A warning about the quality of the move, not a timing trigger.
- Hovering near 0.5 with narrow bands
- Price is pinned to its own average in a compressed regime, the balanced state that usually precedes an expansion.
Limitations
Where this indicator misleads. None of these are fixed by a better parameter.
- It is unbounded above and below, so it cannot be treated like a bounded oscillator with fixed overbought and oversold lines. Fading every reading above one is exactly the wrong behaviour in a trend.
- When the bands are very narrow the denominator is small and %b becomes hypersensitive, swinging from 0 to 1 on trivial price moves. Compression regimes are where the series is least reliable.
- It inherits the standard deviation problem: one outlier bar widens the envelope and instantly pushes %b back toward the middle, making a strongly trending market look neutral.
- Divergences in %b repeat and fail like all divergences, and without an invalidation level the pattern is unfalsifiable.
Educational reference. This page explains how an indicator is built and how it is commonly read. It is not investment advice, not a recommendation and not a signal service. No indicator is profitable on its own — each is a way of describing a market, and any rule built on one has to be tested with realistic costs before it is traded.