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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          66 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X