Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reference error message

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

    Reference error message

    Hi there,

    when I try to run my strategy which passes the compiling however, got problem when I just to run it real. I figure out the problem come from some values, OrderAction.Buy etc., like in the code:
    "if (IO.OrderAction == OrderAction.Buy && (IO.OrderState == OrderState.Working || IO.OrderState==OrderState.Accepted))
    break;"
    I got these error message:"Object reference not set to an instance of object"

    Any ideas about this issue?

    #2
    Majorshi,

    I would suggest putting a Try/Catch in your code to help identify where the issue is coming from if you havent already.



    Could you possibly post more of your code for this section? Where do you define the IO object? Is this in an overrided method like OnOrderUpdate()?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Yes, that's right. These code is located in OnBarUpdate, and the "IO" is a reference to IOrder which is defined the value when generating an order and return with this reference.

      Comment


        #4
        I would suggest you check into this tip here - http://www.ninjatrader.com/support/f...ead.php?t=4226

        Very likely you see this happen as you don't check for null properly before accessing an IOrder property in your code.

        Comment


          #5
          yes, after checking null properly, the problem is solved.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          573 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          576 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X