Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why IOrder may be == NULL?

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

    Why IOrder may be == NULL?

    The quote from help
    // Remember to check the underlying IOrder object for null before trying to access its properties
    if (execution.Order != null && execution.Order.OrderState == OrderState.Filled)
    Print(execution.ToString());

    Well, OK, but how come execution.Order may be NULL? Does it mean that the signal comes from another chart/strategy?

    What kind of the situation is that? Ignorable, important, critical?

    Thanks

    #2
    Hello alex.nt,
    Please refer to this thread where there is already an detailed discussion pertaining to this subject http://www.ninjatrader.com/support/f...rder+reference

    Please do let me know if I can be of any further help.

    Regards,
    Joydeep.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thank you Joy,

      I must admit that I did not get the answer on "why IOrder may be NULL" from that thread.

      Would you mind to shed a light on it?

      Thank you

      Comment


        #4
        Alex, in the more general case and IOrder object would be null when you start using it, it would have no assigned value and if you then would try accessing any of it's properties you would see an object reference error. IOrder objects are set in your code and once they reach terminal state (like fill / cancellation) you would reset / nullify them so you could reuse them on the next action. So for working with them it's very important to check for them not being null before attempting to access any properties.

        Comment


          #5
          Originally posted by alex.nt View Post
          Thank you Joy,

          I must admit that I did not get the answer on "why IOrder may be NULL" from that thread.

          Would you mind to shed a light on it?

          Thank you
          The last post, http://www.ninjatrader.com/support/f...92&postcount=7, gives an explanation of at least one instance.

          Comment


            #6
            Mm-mm, good one but it looks like it is not the only case.

            Moreover, StopLoss/ProfitTarget are not submitted directly from the code and yet they are passed to OnExecution as valid IOrder.

            In any case it does not seem logical to pass orders to the function that "are not orders". I mean it probably has its own explanation but it is a strange-looking implementation...

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            639 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            572 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X