Hi,
I use a very simple rule to enter trades. If previous candle closes green -> then long. If previous candle closes red -> then short.
As an example, for long I use (close[0] > open[0])
Sometimes a candle will close green then enter a short and visa versa.
Is there a better code I can use to implement this instruction correctly?
Thank you in advance!
Kind regards,
Anton
IF NOT ONMARKET THEN
LONGRULE = (close[0] > open[0])
SHORTRULE = (open[0] > close[0])
IF LONGRULE and TradeAllowed=1 THEN
BUY PositionSize CONTRACT AT MARKET
SET TARGET PROFIT TPT //TPT2
SET STOP LOSS SSS //SSS2
ENDIF
IF SHORTRULE and TradeAllowed=1 THEN
SELLSHORT PositionSize CONTRACT AT MARKET
SET STOP LOSS SSS//SSS2
SET TARGET PROFIT TPT//TPT2
ENDIF
ENDIF
I tested it on DAX, 5-min TF, and all entries are correct according to the two rules, GREEN or RED.
What TF and instrument are you using?