Hi,
Possible to have just two lines for MACD? Want the lines to be exponential moving average.
Standard MACD is calculated using exponential averages.
To disable the hystogram just make it INVISIBLE in the indicators’properties.
This is the code for the MACD, if you want to customize it with different averages, you just need to change the variable MAtype:
FastMA = 12 //12 Fast average
SlowMA = 26 //26 Slow average
Periods = 9 //9 periods for the Signal
MAtype = 1 //1=ema average type(see available types https://www.prorealcode.com/documentation/average/)
MyMACD = Average[FastMA,MAtype](close) - Average[SlowMA,MAtype](close) //difference of the two averages
MySignalLine = Average[Periods,MAtype](MyMACD) //average of the MACD
MyHisto = MyMACD - MySignalLine //hystogram
RETURN MyMacd AS "Macd",MySignalLine AS "Signal",MyHisto as "histo"
Still a problem, its not smoothed as the picture. See below
This is not smoothed since it’s the standard one, to smooth the Signal line we need to add a smoothing average:
FastMA = 12 //12 Fast average
SlowMA = 26 //26 Slow average
Periods = 9 //9 periods for the Signal
MAtype = 1 //1=ema average type(see available types https://www.prorealcode.com/documentation/average/)
SmoothPeriods= 20 //20 smppthing periods
SmoothType = 1 //1=ema smoothing average type
MyMACD = Average[FastMA,MAtype](close) - Average[SlowMA,MAtype](close) //difference of the two averages
MySignalLine = Average[Periods,MAtype](MyMACD) //average of the MACD
MySignalLineS= Average[SmoothPeriods,SmoothType](MySignalLine) //average of the SIGNAL line (smoothing)
//MyHisto = MyMACD - MySignalLine //hystogram
MyHisto = MyMACD - MySignalLineS //hystogram (smoothed)
RETURN MyMacd AS "Macd",MySignalLineS AS "Signal",MyHisto as "histo"
you will set the periods and type of any average as best suits your needs. Expnential averages are used by default.
As you can see from the attached pic, the MACD has the same value as the original, while the Signal line has a smoothed value.