//@version=4 study("Trend Filter", overlay=false, shorttitle="Trend Filter") FilterTop = input(3.0,title="Filter Top",step=0.1) FilterBottom = input(-3.0,title="Filter Top",step=0.1) ZeroLine = input(0,title = "ZeroLine", step= 0.01) SRC = input(ohlc4,title="source") Angle(_SRC) => Rad2Degree = 180/3.14159265359 Ang=Rad2Degree*atan((_SRC[0] - _SRC[1])/atr(14)) Ma = ema(SRC,input(56)) Ma_Slope = Angle(Ma) Logic = Ma_Slope > FilterTop ? color.rgb(48, 83, 236) : Ma_Slope < FilterBottom ? color.rgb(131, 4, 4) : color.black AngelMovingAverage = sma(Ma_Slope,20) MaSlopePlotted = plot(Ma_Slope, title="Ma Slope", linewidth=2,color = Logic,style = plot.style_stepline) AngelMAPlotted = plot(AngelMovingAverage,title="Ma Angel", linewidth=1,color = color.rgb(255, 72, 0),style=plot.style_line) hline(FilterTop, title='Filter Top', color=color.rgb(0, 0, 0), linewidth=1) hline(FilterBottom, title='Filter Bottom', color=color.rgb(0, 0, 0), linewidth=1) hline(ZeroLine,title='ZeroLine',color=color.rgb(0, 0, 0), linewidth=1)