shawn4812

MACD DEMA by Toff

MACD DEMA by Toff
converted to version 5
Changed Histogram formatting
Changed MACD plot to indicate macd direction change

//@version=5
//by ToFFF converted to version 5, changed histogram formating changed macd plot to show macd direction changed with lighter color
indicator('MACD DEMA', timeframe = "", timeframe_gaps=true)
sma = input(12,title='DEMA Short')
lma = input(26,title='DEMA Long')
tsp = input(9,title='Signal')
lines = input(true,title="Lines")
col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD")
col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal")
col_macd_i = #0000FF
col_macd_d = #66FFFF

slowa = ta.ema(close,lma)
slowb = ta.ema(slowa,lma)
DEMAslow = ((2 * slowa) - slowb)

fasta = ta.ema(close,sma)
fastb = ta.ema(fasta,sma)
DEMAfast = ((2 * fasta) - fastb)

MACD = (DEMAfast - DEMAslow)

signala = ta.ema(MACD, tsp)
signalb = ta.ema(signala, tsp)
signal = ((2 * signala) - signalb)

hist = (MACD - signal)

//swap1 = MACDZeroLag>0?green:red

plot(hist,style=plot.style_columns, color=(hist>=0 ? (hist < hist ? col_grow_above : col_fall_above) : (hist < hist ? col_grow_below : col_fall_below)),title='HIST')
p1 = plot(lines?MACD:na,style = plot.style_line, color=(MACD < MACD) ? col_macd_i : col_macd_d , linewidth =3,title='MACD')
p2 = plot(lines?signal:na, color=col_signal, linewidth =2,title='Signal')

hline(0)

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?