Linear Weighted MA that changes colors based on slope.
Green = slope up from last bar
Yellow = slope is 0 from last bar
Red = slope down from last bar
Green = slope up from last bar
Yellow = slope is 0 from last bar
Red = slope down from last bar
//@version=2 study("LWMA w/ Color Change", shorttitle="LWMA", overlay=true) p = input(defval=35, title="Period", minval=1) ma = wma(close, 35) c = ma[1] > ma[2] ? green : ma[1] < ma[2] ? red : yellow plot(ma[1], color=c)