Abdul Rehman Trading Strategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © alrehmanansari


//@version=5
indicator("Abdul Rehman Trading Strategy", overlay=true)

TD = 0
TS = 0
TD := close > close[4] ? nz(TD[1])+1 : 0
TS := close < close[4] ? nz(TS[1])+1 : 0
TDUp = TD - ta.valuewhen(TD < TD[1], TD, 1 )
TDDn = TS - ta.valuewhen(TS < TS[1], TS, 1 )

plotshape(TDUp==7?true:na,style=shape.triangledown,color=color.red, text="7", textcolor=color.red, location=location.abovebar)
plotshape(TDUp==8?true:na,style=shape.triangledown,color=color.red, text="8", textcolor=color.red, location=location.abovebar)
plotshape(TDUp==9?true:na,style=shape.labeldown,color=color.red, text="SHORT", textcolor=color.white, location=location.abovebar)


plotshape(TDDn==7?true:na,style=shape.triangleup, color=color.green, text="7", textcolor=color.green, location=location.belowbar)
plotshape(TDDn==8?true:na,style=shape.triangleup, color=color.green, text="8", textcolor=color.green, location=location.belowbar)
plotshape(TDDn==9?true:na,style=shape.labelup, color=color.green, text="LONG", textcolor=color.white, location=location.belowbar)