Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Error

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

    Strategy Error

    I'm getting the following error when Analyzing a strategy:

    Strategy,Error on calling 'OnBarUpdate' method for strategy 'XYZ': Object reference not set to an instance of an object.

    How to debug? How can I find out which line of code in OnBarUpdate is generating the error?



    #2
    imported post

    You will have to add debug print statements to each area of your codethat has a variable that holds an object. Somewhere your code is accessing an object variable that does not hold an object.


    For example:

    if (myObject == null)
    Print("myObjectis null);

    Ray
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      The error is being caused by the following line of code:

      if (Position.GetProfitLoss(Close[0],PerformanceUnit.Points)>=0)



      When I run the code without this conditional statement the error doesn't occur.

      What am I doing wrong? Do I need to initialize the Position object?



      Is there any way to debug NS using VS or another debugger?

      Comment


        #4
        imported post

        - do you have code line below in the OnBarUpdate method? I just tried on a blank strategy and could not experience any issue
        - there is no need to initialize the Position object
        - you can not debug your NS strategy by a debugger. I suggest putting in Print() statements.

        Comment


          #5
          imported post

          Yes, it is in the OnBarUpdate method as part of more code. When I just remove this line and let the rest of the code run, it runs fine. When I add this line as a condition to part of the code (along and shortexit), the object error appears.




          Comment


            #6
            imported post

            Can you please PM me your strategy to "dierk AT ninjatrader DOT com" in order reproduce?

            I also would need:
            - which instrument is this
            - which timeframe (1 minute? else?)
            - please send me a screenshot of your strategy settings as well

            Thanks

            Comment


              #7
              imported post

              Sent by mail.

              Comment


                #8
                imported post

                This is a bug which will be fixed with next update. Thanks for reporting that one.

                Comment


                  #9
                  imported post

                  We created a custom build holding this fix. Please:
                  - uninstall NT6 via control panel
                  - clear your browser cache
                  - install custom build from here: https://www.ninjatrader-support.com/...er.Install.msi

                  Comment


                    #10
                    imported post

                    I'm impressed with the fast turn-around on this.

                    I will test the custom version first thing AM.


                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    628 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    359 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    105 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    562 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    568 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X