StopTrail is executing 2 bars after it's cancelled
-
After my limit is reached I sell half of my position and I open a trailing stop at that point for the rest of the amount to "let it ride". I'm using a strategy on 5m intervals so I'm cancelling any orders at the end of the day (30 mins before). The timeframe of what is happening is that a stock's price hits the limit and half of the position gets sold. Then it hits 3:30 and the other half gets sold and I'm cancelling my trailing stop loss. 10 minutes later my trailing stop loss gets triggered even though it should be cancelled? It then shorts the stock which is then immediately bought back 5mins later since it's past 3:30. Is there some type of issue cancelling trailing stops? Or am I misunderstanding something?
-
you may want to share your script if you need answers. Otherwise it will be long guessing game. Highly likely you are not cancelling the order appropriately.
-
@ab_trader said in StopTrail is executing 2 bars after it's cancelled:
Otherwise it will be long guessing game.
Actually, probably a very short guessing game.
-
@ab_trader @run-out
Do I need more than this?d.orders["limit"].cancel() d.orders["stop"].cancel()
Those are my orders, I confirmed the stop went into a cancelled state. Then it went into a completed state as it executed 10 minutes later
-
-
@ab_trader I believe that was it, I looked at the source code and it looks like calling cancel from the order object simply marks the status as cancelled and doesn't actually cancel the order with the broker. Which was very confusing because of course it wasn't giving an error and when I was printing out the orders they were marked cancelled, but the broker didn't know that.