Change Color on Moving Average

 
I am writing a custom indicator based on the Hull Moving Average. I have the calculation of the moving average done and it displays nicely. The one thing I'm having a problem with is making the line color change depending on whether the line is going up or down. Any help on this will be highly appreciated.
 
There are many samples in the Code Base.See, for example https://www.mql5.com/en/code/mt4
Reason: