//Variables
a=obv(close)
once RefCloseDownOld=0
once RefRSIDownOld=0
once RefCloseUpOld=0
once RefRSIUpOld=0
once BarBullOld=0
once BarBearOld=0
//Conditions to identify max and min
c1=a[4]>a[2] and a[3]>a[2] and a[1]>a[2] and a>a[2]
c2=a[4]<a[2] and a[3]<a[2] and a[1]<a[2] and a<a[2]
//finding the double bottom
if c1 then
RefCloseDownNew=close[2]
RefRSIDownNew=a[2]
BarBullNew=barindex[2]
endif
if RefCloseDownNew<RefCloseDownOld and RefRSIDownNew>RefRSIDownOld then
//double slash next line if you don't needed the mark on a different window
bulldiv=a*0.95
//entry price for long on price window // double slash next line if not needed
//DRAWSEGMENT(BarBullNew, highest[(BarBullnew-BarBullOld)](close), BarBullNew+10, highest[(BarBullnew-BarBullOld)](close))
//entry price for long on RSI window // double slash next line if not needed
if RefRSIDownOld >0 then
DRAWSEGMENT(BarBullOld, RefRSIDownOld *0.99, BarBullNew, RefRSIDownNew *0.99)coloured(255,0,0)
else
DRAWSEGMENT(BarBullOld, RefRSIDownOld *1.01, BarBullNew, RefRSIDownNew *1.01)coloured(255,0,0)
endif
else
bulldiv=0
endif
//Finding the double top
if c2 then
RefCloseUpNew=close[2]
RefRSIUpNew=a[2]
BarBearNew=barindex[2]
endif
if RefCloseUpNew>RefCloseUpOld and RefRSIUPNew<RefRSIUpOld then
//double slash next line if you don't needed the mark on a different window
beardiv=a*0.95
//entry price for short on price window // double slash next line if not needed
//DRAWSEGMENT(BarBearOld, RefCloseUpOld *1.01, BarBearNew, RefCloseUpNew *1.01)coloured(255,0,0)
//entry price for short on RSI window // double slash next line if not needed
if RefRSIUpOld >0 then
DRAWSEGMENT(BarBearOld, RefRSIUpOld *1.01, BarBearNew, RefRSIUpNew *1.01)coloured(255,0,0)
else
DRAWSEGMENT(BarBearOld, RefRSIUpOld *0.99, BarBearNew, RefRSIUpNew *0.99)coloured(255,0,0)
endif
else
beardiv=0
endif
//grafica
RefCloseDownOld=RefCloseDownNew
RefRSIDownOld=RefRSIDownNew
RefCloseUpOld=RefCloseUpNew
RefRSIUpOld=RefRSIUpNew
BarBullOld=BarBullNew
BarBearOld=BarBearNew
return bulldiv coloured (0,255,0) style(histogram,1) , beardiv coloured (255,0,0)style(histogram,1)