Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
        BertrandNinjaTrader Customer Service

        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 andrewtrades, Today, 04:57 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            3 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            436 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            6 views
            0 likes
            Last Post FAQtrader  
            Started by rocketman7, Today, 09:41 AM
            5 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X