Coloring indicator lines based on slope

I am looking for some assistance on coloring a line based on the previous value(positive slope/negative slope). For instance a 50SMA, if current value of 50SMA is greater than value of 50SMA of previous bar, color green. If less than, color red. If equal to, color blue. I have done this using pinescript, but do not have much experience with java.

Thank you!