Open-source scriptindicator/v1
Bollinger Bands Percent B
Show where price sits between the lower and upper Bollinger Bands as a normalized oscillator.
#bollinger-bands#percent-b#volatility
Description
Bollinger %B converts the position of price inside Bollinger Bands into an oscillator. A value of 100 corresponds to the upper band, zero to the lower band, and readings beyond that range indicate price has moved outside the bands.
Open-source script. Everyone can inspect the source code, use the script on a chart, and save an editable copy.
Release notes
Version history · 1 published version
Version 1CurrentChart updatedBollinger Bands Percent B · Aug 31, 2026
Source codempl-2.0View sourceHide source
indicator("Bollinger Bands Percent B", { overlay: false });
const length = input.int("Length", 20, { min: 2, max: 500 });
const mult = input.float("Standard Deviations", 2, { min: 0.1, max: 10, step: 0.1 });
const source = input.source("Source", "close");
const [basis, upper, lower] = bb(source, length, mult);
const percentB = source.map((v, i) => upper[i] === lower[i] ? 50 : 100 * (v - lower[i]) / (upper[i] - lower[i]));
plot(percentB, { title: "%B", color: "#2962ff", lineWidth: 2 });
hline(100, { title: "Upper Band", color: "#ef5350", style: "dashed" });
hline(50, { title: "Middle", color: "#78909c", style: "dotted" });
hline(0, { title: "Lower Band", color: "#26a69a", style: "dashed" });
Community discussion
0 comments
No comments yet. Start the discussion.