//PRC_Doji Heikin Ashi | screener
//10.01.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
DEFPARAM CumulateOrders = false
DEFPARAM PreLoadBars = 0
ONCE StopLossBuy = 0
ONCE StopLossSell = 0
// --- parameters
DojiSize = 5 //x% percent of body size compared to the complete range of the candlestick
// ---
GRAPH StopLossBuy
GRAPH StopLossSell
GRAPH data
GRAPH LongOnMarket
GRAPH LongOnMarket[1]
IF LongOnMarket[1] THEN //Setta lo SL dopo l'entrata LONG
IF StopLossBuy THEN
SET STOP LOSS StopLossBuy
ENDIF
StopLossBuy = 0
StopLossSell = 0
ENDIF
IF ShortOnMarket[1] THEN //Setta lo SL dopo l'entrata SHORT
IF StopLossSell THEN
SET STOP LOSS StopLossSell
ENDIF
StopLossBuy = 0
StopLossSell = 0
ENDIF
//if barindex>1 then
haclose=(open+close+low+high)/4
haopen=(haopen[1]+haclose[1])/2
xHigh = Max(haOpen, haClose)
xLow = Min(haOpen, haClose)
hahigh = Max(High,xHigh)
halow = Min(Low,xLow)
IF Not OnMarket THEN
data=abs(haopen - haclose) <= ((hahigh - halow) * DojiSize/100)
IF data THEN
StopLossBuy = low - (10 * pipsize)
StopLossSell = high + (10 * pipsize)
ENDIF
ELSE
data = 0
ENDIF
//ENDIF
IF data OR (StopLossBuy AND StopLossSell) THEN
PrezzoBuy = high + (10 * pipsize)
IF PrezzoBuy > close THEN
BUY 1 contracts AT StopLossSell STOP
ELSE
BUY 1 contracts AT StopLossSell LIMIT
ENDIF
PrezzoSell = low - (10 * pipsize)
IF PrezzoSell < close THEN
SELLSHORT 1 contracts AT StopLossBuy STOP
ELSE
SELLSHORT 1 contracts AT StopLossBuy LIMIT
ENDIF
ENDIF
//GRAPH StopLossBuy
//GRAPH StopLossSell
//GRAPH data
//GRAPH LongOnMarket
//GRAPH LongOnMarket[1]