glaz

Normalized MACD

Normalized MACD
There are varius options like choosing the moving average to use, sometimes i prefer the wma it is much smoother
Added also macd line to swap color and Fill that plots columns
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?
study("Normalized MACD",shorttitle='N MACD')
sma = input(12,title='Fast MA')
lma = input(21,title='Slow MA')
tsp = input(9,title='Trigger')
np = input(50,title='Normalize')
h=input(true,title='Histogram')
docol = input(false,title="Color Change")
dofill=input(false,title="Fill")
type = input(1,minval=1,maxval=3,title="1=Ema, 2=Wma, 3=Sma")

sh = type == 1 ? ema(close,sma)  
 : type == 2 ? wma(close, sma)
 : sma(close, sma)

lon=type == 1 ? ema(close,lma) 
 : type == 2 ? wma(close, lma)
 : sma(close, lma)

ratio = min(sh,lon)/max(sh,lon)
Mac = (iff(sh>lon,2-ratio,ratio)-1)
MacNorm = ((Mac-lowest(Mac, np)) /(highest(Mac, np)-lowest(Mac, np)+.000001)*2)- 1
MacNorm2 = iff(np<2,Mac,MacNorm)
Trigger = wma(MacNorm2, tsp)
Hist = (MacNorm2-Trigger)
Hist2 = Hist>1?1:Hist<-1?-1:Hist
swap=Hist2>Hist2[1]?green:red
swap2 = docol ? MacNorm2 > MacNorm2[1] ? #0094FF : #FF006E : red
plot(h?Hist2:na,color=swap,style=columns,title='Hist',histbase=0)
plot(MacNorm2,color=swap2,title='MacNorm')
plot(dofill?MacNorm2:na,color=MacNorm2>0?green:red,style=columns)
plot(Trigger,color=yellow,title='Trigger')
hline(0)