tmc

Bollinger Bands Squeeze

source: http://trader-guide.com/bollinger-bands-squeeze/
Remove from Favorite Scripts Add to Favorite Scripts
study("BB Squeeze", scale=scale.right, overlay=true)

//--- Keltner
kLength = input(20, title="Keltner Lenght")
kN = input(1.5, title="Keltner Deviation")
kUpper = sma(close,kLength) + kN*atr(kLength)
kLower = sma(close,kLength) - kN*atr(kLength)

//--- Bollinger
bbLength = input(20, title="Bollinger Length")
bbN = input(2, title="Bollinger Deviation")
bbUpper = sma(close,bbLength) + bbN*stdev(close,bbLength)
bbLower = sma(close,bbLength) - bbN*stdev(close,bbLength)

//--- BB Squeeze
squeeze = bbUpper <= kUpper and bbLower >=kLower

//--- Plots
plot(bbUpper, title="Upper Band")
plot(bbLower, title="Lower Band")

//--- Fill
a = plot(squeeze?bbUpper:na, style=linebr, color=n?na:white, title="Squeezed Upper Band")
b = plot(squeeze?bbLower:na, style=linebr, color=n?na:white, title="Squeezed Lower Band")
fill(a,b, color=yellow, transp=30, title="Squeezed Area")
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out