Thank you for your time and patience.
While testing and working to create an example script that cancels an order via a timer, I considered that the issue might be with historical orders that are transitioned to real-time because a timer would not work on historical processing. This was not the underlying cause of the behavior, though I did want to point it out as a reminder. Timers only work in real time and are not able to be backtested.
What I did find is that CancelOrder() is successful when IsLiveUntilCancelled is true in the order method that submits the order. Otherwise, if it is set to its default value of false, the order is only canceled when the entry condition expires. I have reported this to the development team for further investigation. I will post an update here once I have one.
With that said, if you change your order method to the overload that allows you to set IsLiveUntilCancelled to true, you should see your orders being canceled as expected:
EnterLongLimit(0, true, 1, GetCurrentBid() - (TickSize * 6), orderSignalName);
For more information about live until cancelled orders:
https://ninjatrader.com/support/help...tm#LiveUntilCa ncelledOrders
For working samples demonstrating CancelOrder() both with and without a timer and demonstrated with the managed and unmanaged approaches, please see the attached strategies.
KonstantinosNT please check out the attached examples. You mentioned, "I have sometimes been in the position to wanting to Cancel a specific Order, just a few seconds after my Strategy made it, but I haven't achieved that yet." If you have an example of output that demonstrates a cancellation that was not completed as expected, we would be glad to further investigate. It is important to keep in mind the following notes from the CancelOrder() page in the help guide:
2.An order can be completely filled or part filled in the time that you send the cancel request and the time the exchange receives the request. Check the OnOrderUpdate() method for the state of an order you attempted to cancelled.
Thank you again for your patience and please let me know if I may be of further assistance.

Comment