iamajeya

Squeeze Momentum Indicator [AJ]

121
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.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
// 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)), 
            lengthKC,0)

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)