0% found this document useful (0 votes)
147 views2 pages

MACD Zero-Lag (ATP) PineScript Code - Version6

Uploaded by

ali.btctter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views2 pages

MACD Zero-Lag (ATP) PineScript Code - Version6

Uploaded by

ali.btctter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.

0
at https://mozilla.org/MPL/2.0/
// © AlgoTrade_Pro

//@version=6
indicator(title = 'MACD Zero-Lag [ATP🤖]')

source = close
fastLength = input.int(34, minval = 1)
slowLength = input.int(52, minval = 1)
signalLength = input.int(21, minval = 1)

// FAST LINE
ema1 = ta.ema(source, fastLength)
ema2 = ta.ema(ema1, fastLength)
differenceFast = ema1 - ema2
zerolagEMA = ema1 + differenceFast
demaFast = 2 * ema1 - ema2

// SLOW LINE
emas1 = ta.ema(source, slowLength)
emas2 = ta.ema(emas1, slowLength)
differenceSlow = emas1 - emas2
zerolagslowMA = emas1 + differenceSlow
demaSlow = 2 * emas1 - emas2

//MACD LINE
ZeroLagMACD = demaFast - demaSlow

//SIGNAL LINE
emasig1 = ta.ema(ZeroLagMACD, signalLength)
emasig2 = ta.ema(emasig1, signalLength)
signal = 2 * emasig1 - emasig2

hist = ZeroLagMACD - signal


cHist = hist > 0 ? color.lime : color.red
plot(hist, title = 'histogram', style = plot.style_histogram, color = cHist,
linewidth = 10)
signalLine = plot(signal, title = 'signal', color = color.new(color.red, 0),
linewidth = 1)
zlLine = plot(ZeroLagMACD, title = 'MACD 0 Lag', color = color.new(color.blue, 0))
cDif = hist > 0 ? color.blue : color.red
fill(zlLine, signalLine, color = cDif)

// Detect crossovers for signal generation


up = ta.crossover(ZeroLagMACD, signal)
dn = ta.crossunder(ZeroLagMACD, signal)

// Color definitions
color_up = color.lime
color_dn = color.red

// Plot signals on the chart


plotshape(up, 'BUY Label', shape.triangleup, location.bottom, color_up, 0, 'BUY',
chart.fg_color, true, size.tiny, force_overlay = true)
plotshape(dn, 'SELL Label', shape.triangledown, location.top, color_dn, 0, 'SELL',
chart.fg_color, true, size.tiny, force_overlay = true)

// Color the background on signal occurrences


bgcolor(up ? color.new(color_up, 90) : na, force_overlay = true, editable = true)
bgcolor(dn ? color.new(color_dn, 90) : na, force_overlay = true, editable = true)

//End

You might also like