ApplyStop for Target prices take precedence on Sell Rules on Open

I need help with a problem. I want to sell as soon as the open of the current day is above yesterday Close or Yesterday Open. The rule works fine but there is a problem with the backtester. When the rule should have triggered on candle Open as set by the SellPrice variable, the trade is not executed until the end of the bar therefore if the target price was hit using the stop, it will favor that exit instead of the sell rule on bar open.

IsTheOpenAboveYesterdayOpenOrAboveYesterdayClose = O > Ref(O, -1) OR O > Ref(C, -1);

Buy = GapDown();
Sell = IsTheOpenAboveYesterdayOpenOrAboveYesterdayClose;

targetValue = Ref(ATR(1),-1);


BuyPrice = O;
SellPrice = O;
SetOption("AllowSameBarExit", True );  

Is there anything that can be done as this is great for backtest results but in real life, I will be gone from the trade and it is making the backtest results not match with reality.


This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.