# strategiies_yuan_1

75 0
strategiies_yuan_1
using squeeze momentum, combine with macd and adx
```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, sequeeze happening
// long if it value is larger or green, macd is pos or larger

buy_order_2 = sqzOff and (sqzOn[1]) and (sig > nz(sig[1])) and (nz(sig[1]) > nz(sig[2])) and (sig < 25)

buy_order = sqzOn and (sig > nz(sig[1])) and (nz(sig[1]) > nz(sig[2])) and (sig < 25)
//buy_call = buy_order and (val > 0.05) and (hist1 > 0) and (val > nz(val[1]))
buy_call = (buy_order or buy_order_2) and (hist1 > nz(hist1[1])) and (nz(hist1[1]) > nz(hist1[2])) and (val > nz(val[1])) and (val > nz(val[2]))
//buy_put = buy_order and (val < -0.05) and (hist1 < 0) and (val < nz (val[1]))
buy_put = (buy_order or buy_order_2) and (hist1 < nz(hist1[1])) and (nz(hist1[1]) < nz(hist1[2])) and (val < nz(val[1])) and (nz(val[1]) < nz(val[2]))

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