MACD normalized with its highest and lowest values over the last “inpNormPeriod”.
Classic settings of periods are available. This version embed a small lag smoothing function of the curves for a better reading.
//PRC_Smoothed & Normalized MACD | indicator
//16.10.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//converted from MT5 version
// --- settings
inpFastPeriod = 12 // MACD fast period
inpSlowPeriod = 26 // MACD slow period
inpMacdSignal = 9 // Signal period
inpSmoothPeriod = 5 // Smoothing period
inpNormPeriod = 20 // Normalization period
// --- end of settings
price = customclose
if barindex>inpslowperiod then
alphaf = 2.0/(1.0+Max(inpFastPeriod,1))
alphas = 2.0/(1.0+Max(inpSlowPeriod,1))
alphasig = 2.0/(1.0+Max(inpMacdSignal,1))
alphasm = 2.0/(1.0+Max(inpSmoothPeriod,1))
emaf = emaf[1]+alphaf*(price-emaf[1])
emas = emas[1]+alphas*(price-emas[1])
imacd = emaf-emas
mmax = Highest[inpNormPeriod](imacd)
mmin = Lowest[inpNormPeriod](imacd)
if mmin<>mmax then
nval = 2.0*(imacd-mmin)/(mmax-mmin)-1.0
else
nval = 0
endif
val = val[1] + alphasm*(nval-val[1])
sig = sig[1] + alphasig*(val-sig[1])
endif
//colours
if val>val[1] then
valr=30
valv=144
valb=255
elsif val<val[1] then
valr=244
valv=164
valb=96
endif
if sig>val then
sigr=244
sigv=164
sigb=96
else
sigr=30
sigv=144
sigb=255
endif
return val coloured(valr,valv,valb) style(line,3) as "reg smooth MACD", sig coloured(sigr,sigv,sigb) style(dottedline) as "signal line", 0 coloured(169,169,169) style(dottedline)