//@version=5
strategy("BB Squeeze Breakout", overlay=true,
default_qty_type=strategy.percent_of_equity, default_qty_value=10)
bbLen = input.int(20, "BB Period")
bbStd = input.float(2.0, "BB Std")
sqLb = input.int(50, "Squeeze Lookback")
volMult = input.float(1.2, "Volume Mult")
useVol = input.bool(true, "Use Volume Filter")
basis = ta.sma(close, bbLen)
dev = bbStd * ta.stdev(close, bbLen)
upper = basis + dev
lower = basis - dev
width = (upper - lower) / basis
avgVol = ta.sma(volume, 20)
volOk = not useVol or volume > avgVol * volMult
// Squeeze: width below the 25th percentile over the last 5 candles
widthQ25 = ta.percentile_nearest_rank(width, sqLb, 25)
inSqueeze = ta.lowest(width, 5) < widthQ25
longBO = inSqueeze and close > upper and close[1] <= upper[1] and volOk
shortBO = inSqueeze and close < lower and close[1] >= lower[1] and volOk
if longBO and strategy.position_size == 0
sl = basis
risk = close - sl
strategy.entry("BBs L", strategy.long)
strategy.exit("X", "BBs L", stop=sl, limit=close + risk * 2.5)
if shortBO and strategy.position_size == 0
sl = basis
risk = sl - close
strategy.entry("BBs S", strategy.short)
strategy.exit("X", "BBs S", stop=sl, limit=close - risk * 2.5)
plot(upper, "Upper BB", color.red)
plot(basis, "Mid BB", color.yellow)
plot(lower, "Lower BB", color.green)
plotshape(longBO, "L", shape.triangleup, location.belowbar, color.lime)
plotshape(shortBO, "S", shape.triangledown, location.abovebar, color.red)
Overview
When the band width drops below its 25th percentile and price crosses above or below the bands with optional volume confirmation, it triggers long or short entries. Stop loss is set at the middle band, and take profit is set at 2.5 times the initial risk distance. It plots Bollinger Bands and trade signals directly on the main price chart.
Bollinger Band squeeze detection via width percentile ranking
Volume confirmation filter for breakout validation
Dynamic stop loss set at the Bollinger middle band
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
BB Period
int
20
bbLen
BB Std
float
2.0
bbStd
Squeeze Lookback
int
50
sqLb
Volume Mult
float
1.2
volMult
Use Volume Filter
bool
true
useVol
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.
This strategy detects Bollinger Band squeezes by measuring band width against a threshold. It waits for a confirmed breakout in either direction when bands expand, using optional volume confirmation. Long and short signals trigger on breakout after squeeze. Po
NR7 Range Breakout identifies narrowest range bars over a specified lookback period and trades breakouts beyond their high or low price boundaries. It plots an exponential moving average trend filter alongside visual highlights for range compression and breako
This strategy draws on the price chart and filters directional signals with four optional checks. It compares a fast exponential moving average with a slower one, requires volume above its average when the volume audit is on, and aligns close with a higher-tim
This overlay strategy is built for ES futures on the one-minute chart. It plots a volume-weighted moving average of price opens and standard-deviation bands at Fibonacci ratios, plus a second longer volume-weighted average from a higher-timeframe open. Call an
This price-chart strategy plots a simple moving average and upper and lower bands built from the standard deviation of close, scaled by separate offset inputs. It enters a fixed quantity long when close crosses above the upper band and a fixed quantity short w
This strategy runs on the price chart and enters long when a fast simple moving average crosses above a slow one, and short on the opposite cross, while closing the other side. Entries also need ATR above a filter, a pullback check, a minimum candle-body chang