DEFPARAM CumulateOrders = false
Timeframe(Daily,UpdateOnClose)
Positionsize=1
//C3=TIME=<220000
DojiSize = K4 //0.15
Doji=(abs(Dopen(1) - Dclose(1)) <= (DHigh(1) - Dlow(1)) * DojiSize)
DojiPositionHigh= (Dclose(1)and Dopen(1))>=Dlow(1)+0.666*(DHigh(1) - Dlow(1))
DojiPositionLow= (Dclose(1)and Dopen(1))<=Dlow(1)+0.333*(DHigh(1) - Dlow(1))
if doji and DojiPositionHigh then
Flag=1
else
flag=0
endif
if doji and DojiPositionLow then
Flag=2
else
flag=0
endif
//DojiPositionMiddle
if doji and not DojiPositionHigh and not DojiPositionLow then
Flag=3
else
flag=0
endif
If not ONMARKET and Flag=K1 then //KK=8
Buy positionsize contract at market
EndIf
//IF not ONMARKET and Flag=K1 THEN
//sellshort positionsize CONTRACT AT market
//ENDIF
If longOnMarket AND (BarIndex - TradeIndex) >= K2 Then
Sell at Market
Endif
//If shortOnMarket AND (BarIndex - TradeIndex) >= K2 Then
//exitshort at Market
//Endif
goodmorning,
I’m trying to do a strategy for test, that analyse the position of the body in the Doji candle )high, low or middle) but for some reasons it does not give me any results for test. what I’m doing wrong?
Dojisize is range of body, for example with K4 from 0,1 to 0,4. DojiPositionHigh is in the high third of the daily candle and DojiPositionLow is in the low third of the daily candle
thanks in advance
Alessio
Try using GRAPH on all of your conditions, it is likely that one or more are not ever True?
GRAPH
Also try below in place of Line 22 …
if doji and not DojiPositionHigh OR not DojiPositionLow then //OR in place of and
I’ve tried but it does not change anything. I’ve seen that DojiPositionHigh and DojiPositionLow are not graphed, but §I don’t understand why
Pick 1 bar and use the actual values of that 1 bar in your calculation for DojiPositionHigh and DojiPositionLow and see if your condition is feasible?
Just ideas as sometimes (working on our own)we feel like we are going bonkers?? 😉
Append these lines at the end of your code to spot any incorrect value:
graph doji
graph DojiPositionHigh coloured("Blue")
graph DojiPositionLow coloured("Red")
Doji is OK and identified, while the other two no, at least I see only two straight horizontal lines, one red and one blu, on the zero and the one position
So you know where the issue is, which makes it a bit easier to work out.