DEFPARAM CalculateOnLastBars = 1000
//
// formula del MACD
//
//NediaVeloce = 12
//MediaLenta = 26
//MediaSegnale = 9
MyMACD = ExponentialAverage[MediaVeloce](close) - ExponentialAverage[MediaLenta](close)
MySignalLine = ExponentialAverage[MediaSegnale](MyMACD)
MyHisto = MyMACD - MySignalLine
//
//BluColor = MyMACD > 0 AND MyHisto > MyHisto[1] //non usato perché assunto per difetto
MagentaColor = MyMACD > 0 AND MyHisto < MyHisto[1]
RedColor = MyMACD < 0 AND MyHisto < MyHisto[1]
GreenColor = MyMACD < 0 AND MyHisto > MyHisto[1]
//
t = 255 //255=max. visibilità, 0=invisibile
//
r = 0
g = 0
b = 255 //BLU per difetto
//
IF MagentaColor THEN
r = 255 //MAGENTA (ROSSO + BLU)
ELSIF RedColor THEN
r = 255 //ROSSO
b = 0
ELSIF GreenColor THEN
g = 255 //VERDE
b = 0
ENDIF
RETURN MyMACD coloured(0,197,205,t) AS "Macd",MySignalLine coloured(238,99,99,t) AS "Segnale",MyHisto coloured(r,g,b,t) STYLE(histogram,1) AS "Istogramma"