Indicator · Pine Script v5 · Own pane

Bollinger Bands Breakout Oscillator [LUX]

by theonetrade· code credited to LuxAlgo

The Bollinger Bands Breakout Oscillator measures the magnitude of price breaches beyond upper and lower Bollinger Bands over a specified lookback length.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code73
Settings5inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

73 lines of Pine Script v5 from assets/indicator/bit-exact/bollinger_bands_breakout_oscillator_luxalgo_YaniRMVC.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

bollinger_bands_breakout_oscillator_luxalgo_YaniRMVC.pine
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version=5
indicator("Bollinger Bands Breakout Oscillator [LUX]", "BBands BO [LuxAlgo]")
//------------------------------------------------------------------------------
//Settings
//------------------------------------------------------------------------------
length = input(14)

mult   = input(1.)

src    = input(close)

//Style
bull_css = input(#089981, 'Bullish Color'
  , group = 'Style')

bear_css = input(#f23645, 'Bearish Color'
  , group = 'Style')

//------------------------------------------------------------------------------
//Calculation
//------------------------------------------------------------------------------
stdev = ta.stdev(src, length) * mult
ema   = ta.ema(src, length)

upper = ema + stdev
lower = ema - stdev

bull = 0.
bear = 0.
bull_den = 0.
bear_den = 0.

for i = 0 to length-1
    bull += math.max(src[i] - upper[i], 0)
    bear += math.max(lower[i] - src[i], 0)
    
    bull_den += math.abs(src[i] - upper[i])
    bear_den += math.abs(lower[i] - src[i])
    
bull := bull/bull_den*100
bear := bear/bear_den*100

//------------------------------------------------------------------------------
//Plots
//------------------------------------------------------------------------------
bull_grad = color.from_gradient(bull, 0, 100
  , color.new(bull_css, 100)
  , color.new(bull_css, 50))

bear_grad = color.from_gradient(bear, 0, 100
  , color.new(bear_css, 100)
  , color.new(bear_css, 50))

plot0 = plot(bull
  , color = bull == 0 ? na : bull_css)

plot1 = plot(bear
  , color = bear == 0 ? na : bear_css)

plot2 = plot(0
  , color    = na
  , editable = false)

hline(50, 'Midline')

fill(plot0, plot2
  , color = bull_grad)

fill(plot1, plot2
  , color = bear_grad)

Overview

Bollinger Bands Breakout Oscillator [LUX] calculates an exponential moving average and standard deviation envelope, then aggregates breakout distances relative to absolute deviations to output normalized bullish and bearish values from 0 to 100. It plots distinct bullish and bearish breakout lines with gradient fills in a separate pane alongside a 50 midline. Main settings adjust the band length, multiplier, and price source.

Details

Published by

theonetrade on GitHub

Code credit

LuxAlgo, as written in the script's header

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
lengthint14length
multinput1.mult
srcsourceclosesrc
Bullish Colorcolor#089981bull_css
Bearish Colorcolor#f23645bear_css
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Chop and Explode

by capissimo
114 stars

This indicator measures market consolidation and breakout phases by computing a scaled Relative Strength Index (RSI) on normalized price data. It identifies chop zones when the RSI oscillates between 40 and 60, highlighting tight consolidation between 45 and 5

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 years ago · None stated GitHub repository of Chop and Explode

Squeeze Momentum

by mihakralj
99 stars

This indicator plots Squeeze Momentum in a separate pane. It compares Bollinger Bands with a Keltner Channel to mark a squeeze when the bands sit inside the channel. Momentum is a linear regression of price relative to a Donchian midline and an SMA, shown as a

Indicator v6 Volatility & bandsOscillators & momentum
Updated 8 weeks ago · Apache-2.0 GitHub repository of Squeeze Momentum

Renko Acceleration

by f-cksociety
11 stars

Calculates the time elapsed between consecutive bars to measure market speed and volatility, designed primarily for Renko chart blocks where bar duration varies. In Momentum mode, it contrasts the current duration against a 100-period moving average baseline,

Indicator v4 Volatility & bandsOscillators & momentum
Updated 4 years ago · MPL-2.0 GitHub repository of Renko Acceleration

MACD Breakout

by jerryinyang
5 stars

This indicator plots a higher-timeframe MACD breakout setup on the price chart and combines it with linear regression channels. It marks support and resistance zones from MACD histogram sensitivity, then filters them with the MACD zero line, a linear regressio

Indicator v4 Oscillators & momentumBreakout
Updated 2 years ago · None stated GitHub repository of MACD Breakout

Squeeze Panel

by amico1234
1 stars

Squeeze Panel plots a volatility squeeze in a separate pane. It marks a squeeze when Bollinger Bands sit inside a Keltner Channel and marks when the bands expand outside it. The user chooses Money Flow Index or linear regression to color likely breakout direct

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 years ago · None stated GitHub repository of Squeeze Panel

Raschke Patterns

by TradersPost
228 stars

This overlay indicator marks Linda Raschke short-term bar setups on the price chart. It flags Turtle Soup and Turtle Soup plus one false breakouts of a prior extreme, 80-20 bars, inside bars, failed inside-bar breakouts, outside up and down bars, NR4 and NR7 c

Indicator v6 Candlestick patternsBreakout Repaints
Updated 4 months ago · None stated GitHub repository of Raschke Patterns

More Volatility & bands scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers