Code Library / Bollinger Bands
Pine Script BB Squeeze
BB squeeze detector identifying low volatility before big moves.
Language: Pine Script · Category: Bollinger Bands · Tags: Bollinger Bands, squeeze, Pine Script, volatility, breakout
Source code
//@version=5
indicator("BB Squeeze",overlay=false)
b=ta.sma(close,20); bd=2*ta.stdev(close,20)
kcr=ta.atr(20)*1.5; kcb=ta.ema(close,20)
sqz=b-bd>kcb-kcr and b+bd<kcb+kcr
mom=ta.linreg(close-b,20,0)
plot(mom,"Mom",mom>0?color.green:color.red,2,plot.style_histogram)
plotshape(sqz,"Sqz",shape.diamond,location.bottom,color.orange,size=size.tiny)How to use this snippet
This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.