# Squeeze Momentum Indicator

1309 0
Combine:

"TTM Squeeze" by John Carter: https://www.youtube.com/watch?v=lbmUfauTGkU
```study(shorttitle = "SQZMOM_LB_yzong", title="Squeeze Momentum Indicator")

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")
dilen = input(14, title="DI Length")
useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)
use_wave_a = input(true, title = "Wave A", type=bool)
use_wave_b = input(false, title = "Wave B", type=bool)
use_wave_c = input(true, title = "Wave C", type=bool)

// ******* SQZ_MOM ******* //
// 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

// Calcultae SQZ
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

dirmov(len) =>
up = change(high)
down = -change(low)
truerange = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
[plus, minus]

[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

// ******* MACD ******* //

// WAVE CALC
// Wave A
fastMA1 = use_wave_a ? ema(close, 8) : na
slowMA1 = use_wave_a ? ema(close, 34) : na
macd1 =  use_wave_a ? fastMA1 - slowMA1 : na
signal1 =  use_wave_a ? ema(macd1, 34) : na
hist1 =  use_wave_a ? macd1 - signal1 : na

fastMA2 = use_wave_a ? ema(close, 8) : na
slowMA2 = use_wave_a ? ema(close, 55) : na
macd2 = use_wave_a ? fastMA2 - slowMA2 : na
signal2 = use_wave_a ? ema(macd2, 55) : na
hist2 = use_wave_a ? macd2 - signal2 : na

// Wave B
fastMA3 = use_wave_b ? ema(close, 8) : na
slowMA3 = use_wave_b ? ema(close, 89) : na
macd3 = use_wave_b ? fastMA3 - slowMA3 : na
signal3 = use_wave_b ? ema(macd3, 89) : na
hist3 = use_wave_b ? macd3 - signal3 : na

fastMA4 = use_wave_b ? ema(close, 8) : na
slowMA4 = use_wave_b ? ema(close, 144) : na
macd4 = use_wave_b ? fastMA4 - slowMA4 : na
signal4 = use_wave_b ? ema(macd4, 144) : na
hist4 = use_wave_b ? macd4 - signal4 : na

// Wave C
fastMA5 = use_wave_c ? ema(close, 8) : na
slowMA5 = use_wave_c ? ema(close, 233) : na
macd5 = use_wave_c ? fastMA5 - slowMA5 : na
signal5 = use_wave_c ? ema(macd5, 233) : na
hist5 = use_wave_c ? macd5 - signal5 : na

fastMA6 = use_wave_c ? ema(close, 8) : na
slowMA6 = use_wave_c ? ema(close, 377) : na
macd6 = use_wave_c ? fastMA6 - slowMA6 : na
signal6 = use_wave_c ? ema(macd6, 377) : na
hist6 = use_wave_c ? macd6 -signal6 : na

// ******* Config ******* //
// if ADX is below 20/25, sequeeze happening
// buy when ADX is up, macd up, val is larger than previous

// buy order 1: during sqz on
// buy order 2: the first grey after sqz on
buy_order_1 = sqzOn and (sig > nz(sig[1])) and (nz(sig[1]) > nz(sig[2])) and (sig < 25)
buy_order_2 = sqzOff and (sqzOn[1]) and (sig > nz(sig[1])) and (nz(sig[1]) > nz(sig[2])) and (sig < 25)
buy_order_3 = (sig - nz(sig[1])) >= 0.35
buy_order_4 = (sig - nz(sig[2])) >= 0.50

// go long 1: macd is continuously up in last 3 time bar
// go long 2: val is continuously up in last 3 time bar
// go long 3: val is from red to green
// go long 4: val is from drak green to light green
// go long 5: val diff
// go long 6: macd from - to +
// go long 7: macd from + to ++ or -- to -
// go long 8: macd diff
go_long_1 = (hist1 > nz(hist1[1])) and (nz(hist1[1]) > nz(hist1[2]))
go_long_2 = (val > nz(val[1])) and (val > nz(val[2]))
go_long_3 = val > 0 and nz(val[1]) < 0
go_long_4 = val > 0 and nz(val[1]) > 0 and (val > nz(val[1]))
go_long_5 = abs((val - nz(val[1]))) >= 0.005

// go short 1: macd is continuously down in last 3 time bar
// go short 2: val is continuously down in last 3 time bar
// go short 3: val is from green to red
// go short 4: val is from drak red to light red
// go short 5: val diff
// go short 6: macd from + to -
// go short 7: macd from ++ to + or - to --
// go short 8: macd diff
go_short_1 = (hist1 < nz(hist1[1])) and (nz(hist1[1]) < nz(hist1[2]))
go_short_2 = (val < nz(val[1])) and (val < nz(val[2]))
go_short_3 = val < 0 and nz(val[1]) > 0
go_short_4 = val < 0 and nz(val[1]) < 0 and (val < nz(val[1]))
go_short_5 = abs((val - nz(val[1]))) >= 0.005

// PLOT
plot(val, color=bcolor, style=histogram, linewidth=4)
plot(0, color=scolor, style=cross, linewidth=2)

```
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 繁體中文
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