iamajeya

Squeeze Momentum Indicator [AJ]

405 0 47
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)), 
            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)
English
English (UK)
English (IN)
Deutsch
Français
Español
Italiano
Polski
Türkçe
Русский
Português
Bahasa Indonesia
Bahasa Melayu
ภาษาไทย
Tiếng Việt
日本語
한국어
简体
台灣
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