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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          64 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          35 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          59 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          62 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          51 views
          0 likes
          Last Post CarlTrading  
          Working...
          X