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.
1 user thanked author for this post.