LazyBear

Squeeze Momentum Indicator [LazyBear]



Fixed a typo in the code where BB multiplier was stuck at 1.5. Thanks @ucsgears for bringing it to my notice.

Updated source: http://pastebin.com/UCpcX8d7

Use the updated source instead of the what TV shows below.



This is a derivative of John Carter's "TTM Squeeze" volatility indicator, as discussed in his book "Mastering the Trade" (chapter 11).

Black crosses on the midline show that the market just entered a squeeze ( Bollinger Bands are with in Keltner Channel). This signifies low volatility , market preparing itself for an explosive move (up or down). Gray crosses signify "Squeeze release".

Mr.Carter suggests waiting till the first gray after a black cross, and taking a position in the direction of the momentum (for ex., if momentum value is above zero, go long). Exit the position when the momentum changes (increase or decrease --- signified by a color change). My (limited) experience with this shows, an additional indicator like ADX / WaveTrend, is needed to not miss good entry points. Also, Mr.Carter uses simple momentum indicator , while I have used a different method (linreg based) to plot the histogram.

More info:
- Book: Mastering The Trade by John F Carter
- Using Squeeze with ADX: http://www.tradethemarkets.com/public/mastering-the-trade-chapter-11-squeeze.cfm

List of all my indicators:

Remove from Favorite Scripts Add to Favorite Scripts
//
// @author LazyBear 
// List of all my indicators: https://www.tradingview.com/v/4IneGo8h/
//
study(shorttitle = "SQZMOM_LB", title="Squeeze Momentum Indicator [LazyBear]", overlay=false)

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 = multKC * 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 
plot(val, color=bcolor, style=histogram, linewidth=4)
plot(0, color=scolor, style=cross, linewidth=2)
Thank you for helping Tradingview community ;A great script ; This script has helped me to derive a concrete Entry and Exit points for my strategy indicator of LongBuyLongSell auto indicator.Thank your for the great indicator.

+1 Reply
MarxBabu MarxBabu
@MarxBabu, 5min version, with the help of some of the above said logic has reduced lot of noise in the profit maximizer .Thank you don for your support .

Reply
That syntax blows my mind :) How is it possible. If I get mouse over "close" variable I get an explanation: "Current close price, type: float". Hm ok. But how can be this possible:
sma(close,lengthKC)

how we can calculate SMA if we have just one close value? What a language... :) crazy language :)
+6 Reply
Why do we have here a line:
source = close

What does this line give us? Why don't we just use "close" variable instead of creating new "source" variable which is just a copy of "close" array?
Reply
Nidalas RunForrestRun
@RunForrestRun, Probably to be able to change the source easily in all the functions at once. Say you want to use opening of candles instead, then you just have to change source=close into source=open, instead of changing "close" to "open" in all the 4 times it is used
Reply
@Nidalas, that makes sense, thanks!
Reply
If I may ask...what do the blue crosses represent?
Reply
cryptotaku phshbone
+1 (same here)
Reply
nDman_sk cryptotaku
@cryptotaku, black = squeeze, gray = squeeze released, blue = no squeeze
Reply
Really a Great Work Done By @LazyBear hats off to your work man;I love it very much ;in fact it helps us to formulate our own strategy in better way
Reply
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
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 العربية
HE עברית
Home Stock Screener Forex Screener Crypto Screener 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