Squeeze Momentum Indicator [AJ]

323 0 32
Modified LazyBear's indicator to display on top of price. This makes visualizing it much easier and allows you to clearly focus on price action along with the squeeze.
Remove from Favorite Scripts Add to Favorite Scripts
// Re-written by AJ to show on main chart
// Original @author LazyBear 
// List of all my indicators: https://www.tradingview.com/v/4IneGo8h/
study(shorttitle = "AJ_SQZMOM", title="Squeeze Momentum Indicator [AJ]", overlay=true)

length = input(20, title="BB Length")
mult = input(2.0,title="BB MultFactor")
lengthKC=input(20, title="KC Length")
multKC = input(1.5, title="KC MultFactor")

useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)

// Calculate BB
source = close
basis = sma(source, length)
dev = mult * stdev(source, length)
upperBB = basis + dev
lowerBB = basis - dev

// Calculate KC
ma = sma(source, lengthKC)
range = useTrueRange ? tr : (high - low)
rangema = sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC

sqzOn  = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz  = (sqzOn == false) and (sqzOff == false)

val = linreg(source  -  avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)), 

bcolor = iff( val > 0, 
            iff( val > nz(val[1]), lime, green),
            iff( val < nz(val[1]), red, maroon))
scolor = noSqz ? blue : sqzOn ? black : gray 

kccolor = noSqz ? white : sqzOn ? fuchsia : blue
bbcolor = noSqz ? white : sqzOn ? fuchsia : green
sqzwidth = noSqz ? 2 : 4
//plot(val, color=bcolor, style=histogram, linewidth=4)
//plot(0, color=scolor, style=cross, linewidth=2)

// plot KC and BB
plot(ma, title="Keltner Channel MA", color=kccolor, style=line, linewidth=1, transp=80)
plot(upperKC, title="Keltner Channel Upper Line", color=kccolor, style=line, linewidth=2, transp=70)
plot(lowerKC, title="Keltner Channel Lower Line", color=kccolor, style=line, linewidth=2, transp=70)

plot(basis, title="Bollinger Band Mean", color=bbcolor, style=line, linewidth=1, transp=80 )
plot(upperBB, title="Bollinger Band Upper Band", color=bbcolor, style=line, linewidth=2, transp=70)
plot(lowerBB, title="Bollinger Band Lower Band", color=bbcolor, style=line, linewidth=2, transp=70)
United States
United Kingdom
Home Stock Screener Forex Signal Finder 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