Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What fields of an Order object can be null?

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

    What fields of an Order object can be null?

    I'm trying to find an error in my code... anyone know what fields of an Order object can be null? Even if the member can be null for a moment before being filled

    For example can order.Name be null or is it defaulted to an empty string?

    Same question goes for all other members of the Order object? Are all the enum members always non-nullable? Etc.

    I'm getting an "Object reference not set to an instance of an Object" error.

    TIA
    Last edited by defa0009; 04-22-2025, 12:41 PM.

    #2
    Hello defa0009,

    Thank you for your post.

    Are you using CreateOrder() to create an order?

    From a quick test it seems like you can leave the Name parameter as null without hitting an Object reference error (although I wouldn't recommend doing this since it would be difficult to identify the order from ExecutionUpdate, OrderUpdate, etc.). I created an order via CreateOrder(), left the name parameter as null, and tried printing order.Name without hitting any errors (looks like it defaults to the empty string).

    Have you identified which line of code is hitting the Object reference error?

    Comment


      #3
      Originally posted by NinjaTrader_Gaby View Post
      Have you identified which line of code is hitting the Object reference error?
      Thanks for testing... no haven't been able to identify where the error is yet. Working my way down the list.

      The start of the code loops through all orders and I was suspicous if the order.Name was causing the error... would have been an easy fix if it was.

      I take it all other members of the Order object are non- nullable enum values and primitive values?

      Comment


        #4
        Most should not be null, no, as they would be essential to define the order (instrument, orderAction, orderType, etc).

        From a quick test, it seems the Name, Oco, and customOrder parameters can safely be null.

        I would recommend debugging to identify which line is causing the error. It's also good practice to add null checks to make sure an object exists before trying to access it.



        Please let me know if you need further guidance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        331 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        550 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X