study(title="Trend inputs", shorttitle="TI", precision=2) src = hl2 // Input parameters fastMALength = input(34, minval=1, title="Fast Length") slowMALength = input(89, minval=1, title="Slow Length") signalMALen = input(13, title="Signal MA") fastMA = ema(src, fastMALength ) slowMA = ema(src, slowMALength ) trendStrength = (fastMA - slowMA)*100/slowMA signalMA = sma(trendStrength, signalMALen) momentum = trendStrength-signalMA momColor = momentum>0 and change(momentum)>0 ? green : momentum>0 and change(momentum)<0 ? green : momentum<0 and change(momentum)>0 ? red : momentum<0 and change(momentum)<0 ? red : gray plot(momentum, style=histogram, linewidth=2, color=momColor) plot(0, color=change(momentum)>=0?green:red, linewidth=3)