In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.
// Jack Calo -- v1.0 -- 08/26/2016 // Plot an EMA lime green when it's going up and red when it's going down. study(title = "EMA Up/Down Color", overlay=true) ema1 = input(20, minval=1, maxval=300, title="EMA Period") ema1_width = input(2, minval=1, maxval=10, title="Line Width") curEma = ema(close, ema1) col = curEma >= curEma ? lime : red plot(curEma, title="EMA Plot", color=col, linewidth=ema1_width, style=line)