Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error messages - strategies won't start

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

    Error messages - strategies won't start

    I am geting the following error message in my logs Error on calling 'OnBarUpdate' method for strategy ' ': Object reference not set to an instance of an object.

    I am also getting additional errors as follows. Unable to restore strategy ' '. Most likely this strategy no longer is supported by the custom assemblies.

    I don't know what I have done wrong here. I tried uninstalling the program and restored without Ninjascript files but after trying to reload my custom indicators and strategies the same messages are appearing. What can I do from here?

    #2
    suprsnipes, you can ignore the restore error, this simply means it a persisted / saved instance would refer to a no longer installed anymore script.

    The error on calling OnBarUpdate() is a programming issue in your code, somewhere you try accessing an empty object leading to this error and script termination then. Most often we see this as IOrder objects are not properly used -

    Comment


      #3
      OK, found the problem, thanks. Removing the following fixed the errors but what exactly have I done wrong with the code. I simply added this in to cancel the order if it wasn't filled within 10 bars.

      I placed in the variables section

      Code:
      private int barNumberOfOrder            = 0;
      Then in OnBarUpdate if a condition was true

      Code:
      barNumberofOrder = CurrentBar;
      Then at the bottom of OnBarUpdate

      Code:
      if (CurrentBar > barNumberOfOrder + 10)
      CancelOrder(entryOrder);
      barNumberOfOrder = 0;

      Comment


        #4
        Glad to hear, yes likely tied to the tip I referred you to in my prior post. So you were using the entryOrder IOrder object for your entry in your script?

        Comment


          #5
          Yes I am using the entryOrder IOrder object in my script

          Comment


            #6
            Were you checking this for being null before accessing?

            Comment


              #7
              I am checking the entryOrder == null before entering but I only started getting the errors when I tried to cancel the order by using the code in my second post, this is where the problem is I think? Do I need to check the barNumberOfOrder as well?

              I placed in the variables section

              Code:
               
               private int barNumberOfOrder            = 0; 
              Then in OnBarUpdate if a condition was true
              
              barNumberofOrder = CurrentBar; 
              Then at the bottom of OnBarUpdate
              
              if (CurrentBar > barNumberOfOrder + 10) CancelOrder(entryOrder); barNumberOfOrder = 0;

              Comment


                #8
                No, the barnumber should be fine, it's just an integer you keep track with.

                You likely tried to cancel the order (hence accessing entryOrder with the CancelOrder call) when there was no order present, so if you include a check for null as well here it should be ok.

                Comment


                  #9
                  I think this is what you mean...

                  Code:
                  if (entryOrder != null && CurrentBar > barNumberOfOrder + 10)
                  Thanks again.

                  Comment


                    #10
                    Yes, correct that would ensure you only attempt to cancel the order if the object holds one.

                    Comment


                      #11
                      error message re script

                      Ive gotten the error message of "custom ninjascript files on pc have erros that must be reslved before u ca import a ninjascript archive file"

                      Comment


                        #12
                        To resolve this issue I would suggest checking through those steps here - http://www.ninjatrader.com/support/f...ead.php?t=4678

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        663 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        376 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        110 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        575 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        580 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X