Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged Orders -Setting order to null verses canceling it

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Unmanaged Orders -Setting order to null verses canceling it

    What is the difference between setting an order=null verses using the Cancel Method?

    #2
    Hello Cowpux,

    Setting the variable to null, causes the variable to no longer hold the IOrder object. This does not cancel the order, or cause the IOrder object that was once held to be changed at all, it simply removes the IOrder object from the variable and replaces this with a null value.

    Calling CancelOrder() causes NinjaTrader to send a cancellation request to the brokerage so that the order is cancelled on their end. When calling this, it does not remove the IOrder object from the variable. This means the order will still be attached to the variable but the IOrder will have the OrderState equal to OrderState.Cancelled.

    Setting the variable to null after an order is cancelled or rejected allows for you to detect this in the script when placing a new order. This is more of a coding style than required though.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    152 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    87 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    131 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    127 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    106 views
    0 likes
    Last Post CarlTrading  
    Working...
    X