defparam cumulateorders=false
body = ABS(open-close)
bearishwick = ABS(high-close)
bearishnose = ABS(close-low)
bullishwick = ABS(close-low)
bullishnose = ABS(high-close)
//bearish pinbar
bearish= (body/bearishwick)<20/100 AND (body/bearishnose)>100/100
//bullish pinbar
bullish= (body/bullishwick)<20/100 and (body/bullishnose)>100/100
if not longonmarket and bullish then
buylevel = medianprice
buysl = low
buytp = close+(close-low)*2
buystart = barindex
buy at buylevel stop
sell at buysl stop
sell at buytp limit
endif
if longonmarket then
if close<buylevel and barindex-buystart<=5 then
buy at buylevel stop
endif
sell at buysl stop
sell at buytp limit
endif
if not shortonmarket and bearish then
selllevel = medianprice
sellsl = high
selltp = close-(high-close)*2
sellstart = barindex
sellshort at selllevel stop
exitshort at sellsl stop
exitshort at selltp limit
endif
if shortonmarket then
if close>selllevel and barindex-sellstart<=5 then
sellshort at selllevel stop
endif
exitshort at sellsl stop
exitshort at selltp limit
endif
//graphonprice buytp