Squeeze Momentum Indicator [AJ]

492 0 60
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)
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out