← Script Marketplace
Open-source scriptindicator/v1

Bollinger Bands Percent B

by Kodexius·@kodexius·

Show where price sits between the lower and upper Bollinger Bands as a normalized oscillator.

#bollinger-bands#percent-b#volatility
Bollinger Bands Percent B chart preview

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
Release notes

Initial classic indicator release.

View current source ↓
Source codempl-2.0View 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

Loading…

No comments yet. Start the discussion.