Recently I try to develop a strategy based on my own indicator.
The indicator is working fine and it is related to imbalances. Its CalculationMode is OnBarClose because during the bar development the imbalance may change, so I need to wait until the end of the bar before analyse the volumes at each price levels and conclude if there is imbalances in some levels.
On the other side, the strategy is using Calculate.OnEachTick, because I need a tick precision for the stopLoss and takeProfit positions handling. This way the strategy Calculate mode override the indicators's Calculate mode. That is fine for me and I think there is nothing to related to this problem because on the other time all the orders are executed as expected. The strategy is run with TickReplay on ES for 1 week test period. I am connected to live market data during the back-testing and also I have the MarketReplay historical data downloaded locally.
However, during back-testing I got some strange behaviour on the strategy side. It seems like there are case where stopLosses are not executed properly and I do not know why.
I wish to use Managed approach for OCO orders handling using SetStopLoss() and SetProfitTarget(). I also needed and impelemted a trailing stop loss using the SetStopLoss(Calculate.Price), but I do not think this is the problem.
I attach the code, TraceOrders only for one of the screenshots, and some additional logging from the strategy output that is showing that the current UnrealizedProfitAndLoss is more than the stop loss.
Any ideas why there is no stop losses executed?
Best wishes

Comment