Bahri ind

//version=5
indicator("MACD DEMA + Squeeze Momentum", shorttitle='MACD DEMA + SQZMOM', overlay=false)

// Inputs for MACD DEMA
sma = input.int(12, title='DEMA Courte')
lma = input.int(26, title='DEMA Longue')
tsp = input.int(9, title='Signal')
dolignes = input.bool(true, title="Lignes")

// Calculate DEMA
MMEslowa = ta.ema(close, lma)
MMEslowb = ta.ema(MMEslowa, lma)
DEMAslow = (2 * MMEslowa) - MMEslowb

MMEfasta = ta.ema(close, sma)
MMEfastb = ta.ema(MMEfasta, sma)
DEMAfast = (2 * MMEfasta) - MMEfastb

LigneMACDZeroLag = DEMAfast - DEMAslow

MMEsignala = ta.ema(LigneMACDZeroLag, tsp)
MMEsignalb = ta.ema(MMEsignala, tsp)
Lignesignal = (2 * MMEsignala) - MMEsignalb

MACDZeroLag = LigneMACDZeroLag - Lignesignal

swap1 = MACDZeroLag > 0 ? color.green : color.red

plot(MACDZeroLag, color=swap1, style=plot.style_columns, title='Histo', histbase=0)
p1 = plot(dolignes ? LigneMACDZeroLag : na, color=color.blue, title='LigneMACD')
p2 = plot(dolignes ? Lignesignal : na, color=color.red, title='Signal')
fill(p1, p2, color=color.blue)
hline(0)

// Inputs for Squeeze Momentum Indicator
length = input.int(20, title="BB Length")
mult = input.float(2.0, title="BB MultFactor")
lengthKC = input.int(20, title="KC Length")
multKC = input.float(1.5, title="KC MultFactor")
useTrueRange = input.bool(true, title="Use TrueRange (KC)")

// Calculate Bollinger Bands (BB)
source = close
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upperBB = basis + dev
lowerBB = basis - dev

// Calculate Keltner Channels (KC)
ma = ta.sma(source, lengthKC)
trueRange = useTrueRange ? ta.tr : (high - low) // 'range' yerine 'trueRange' kullanıldı
rangema = ta.sma(trueRange, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC

// Squeeze conditions
sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz = not sqzOn and not sqzOff

val = ta.linreg(source - math.avg(math.avg(ta.highest(high, lengthKC), ta.lowest(low, lengthKC)), ta.sma(close, lengthKC)), lengthKC, 0)

bcolor = val > 0 ? (val > nz(val[1]) ? color.lime : color.green) : (val < nz(val[1]) ? color.red : color.maroon)
scolor = noSqz ? color.blue : (sqzOn ? color.black : color.gray)

plot(val, color=bcolor, style=plot.style_histogram, linewidth=4)
plot(0, color=scolor, style=plot.style_cross, linewidth=2)
Technical IndicatorsTrend Analysis

면책사항