//@version=6
// Example script bundled with DegenView. Edit it freely.
// Bollinger Bands, with the background tinted when the bands are the narrowest
// they have been for a while: a "squeeze", which often comes before a big move.
indicator("Bollinger Squeeze", overlay = true)
length = input.int(20, "Length", minval = 2, group = "Bands")
mult = input.float(2.0, "Multiplier", minval = 0.1, step = 0.1, group = "Bands")
lookback = input.int(100, "Squeeze lookback", minval = 10, group = "Squeeze", tooltip = "A squeeze is the narrowest the bands have been over this many bars.")
[middle, upper, lower] = ta.bb(close, length, mult)
width = (upper - lower) / middle
squeeze = width <= ta.lowest(width, lookback)
plot(middle, "Basis", color = color.orange)
top = plot(upper, "Upper", color = color.blue)
bottom = plot(lower, "Lower", color = color.blue)
fill(top, bottom, color = color.new(color.blue, 90), title = "Band fill")
bgcolor(squeeze ? color.new(color.yellow, 80) : na)
Overview
Bollinger Squeeze measures normalized band width to detect squeeze conditions where the bands contract to their narrowest point over a specified historical lookback period. The script plots the basis line and upper/lower channel boundaries directly on the price chart, filling the space between the bands. When a squeeze is detected, it highlights the chart background to signal potential upcoming volatility expansion.
Standard Bollinger Bands with upper, lower, and basis plots
Volatility squeeze detection based on historical band width
Visual background highlighting during squeeze periods
Customizable length, multiplier, and squeeze lookback settings
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Length
int
20
length
Multiplier
float
2.0
mult
Squeeze lookback
int
100
lookback
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.
The Hampel Filter indicator identifies and filters out price outliers to smooth price data directly on the main chart. It calculates the rolling median and Median Absolute Deviation (MAD) of the chosen source series over a specified length. When a data point e
This overlay indicator plots a Supertrend from an ATR length and factor, four exponential moving averages, and a selectable VWAP or TWAP taken from a chosen timeframe on the price chart. It also shows MACD and stochastic with adjustable lengths, smoothing, ver
This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre
This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B
This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre
This indicator calculates an outlier-filtered moving average based on statistical filtering concepts. It stores close prices in a rolling array over a user-defined length, calculates the mean and standard deviation, and excludes values falling within a specifi