Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

ERROR: Failed to call method 'Initialize' for indicator

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

    ERROR: Failed to call method 'Initialize' for indicator

    What does this mean? YRecent is an indicator I developed myself, but I'm currently not using it on any charts... but this always shows up in my logs:

    2009-12-06 16:42:50:421 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.
    2009-12-06 16:44:33:296 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.
    2009-12-06 17:14:49:265 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.
    2009-12-06 17:22:18:734 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.
    2009-12-06 17:23:08:718 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.

    How do I fix it?

    #2
    NinjaCustomer, expected - since the Initialize() is called each time across studies, you could comment out the part giving you the issue or debug the script -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      NinjaCustomer, expected - since the Initialize() is called each time across studies, you could comment out the part giving you the issue or debug the script -

      http://www.ninjatrader-support2.com/...ead.php?t=3418
      just so you know, my indicator works fine and compiles fine...

      it is just that i get this error message in the log...

      could this be the culprit? I have this code in Initialize:

      new DataSeries(this);

      Comment


        #4
        Yes, as this alone is not a fully assigned DataSeries object - http://www.ninjatrader-support.com/H...iesObject.html
        BertrandNinjaTrader Customer Service

        Comment


          #5
          so what should I do?

          I see no difference between my code and what you have in the Help documentation link you gave me, so do I just ignore this error message? it is harmless?

          Comment


            #6
            btw. that was just a code fragment, of course I assigned it to a variable

            Comment


              #7
              You want to assign to a data series variable created in the variables section of your code -

              Code:
               
              protected override void Initialize() 
              { 
                  myDataSeries = new DataSeries(this); 
              }
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Please post your full Initialize() then, thanks.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  just remember when reading the code, that everything works as I intended in the indicator... it is only those log error messages that make me concerned that i am writing sloppy code... i just want to rule out that my indicator could cause any instability (because of those error messages):

                  Code:
                          protected override void Initialize()
                          {
                              
                  			lastHighCache = new ArrayList();
                  			lastLowCache = new ArrayList();
                  
                  			swingHighSeries	= new DataSeries(this);
                  			swingHighSwings	= new DataSeries(this);
                  			swingLowSeries	= new DataSeries(this);
                  			swingLowSwings	= new DataSeries(this);
                  
                  			prevSwingRange = -1;
                  			
                  			BarsRequired = 100;
                  			
                  			AutoScale           = false;
                  			DisplayInDataBox	= false;
                              CalculateOnBarClose	= true;
                  			PaintPriceMarkers	= false;
                              Overlay				= true;
                  			
                  			ActiveMarketLogFile = Environment.GetFolderPath(Environment.SpecialFolder.Personal) +
                  	                                    @"\misc\" + Instrument.MasterInstrument.Name + "_active_market_alerts.csv";
                  			
                  			if (logActiveMarketAlerts) File.Delete(ActiveMarketLogFile);
                          }

                  Comment


                    #10
                    Please move the log file calls accessing the Instrument to the first OnBarUpdate() bar and then retry.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      so I should just put it in a

                      if (CurrentBar == 0) {

                      }

                      in OnBarUpdate ?

                      Comment


                        #12
                        Yes, as the Instrument would likely be emtpy (null) if not placed there...
                        BertrandNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by kevinenergy, 02-17-2023, 12:42 PM
                        118 responses
                        2,778 views
                        1 like
                        Last Post kevinenergy  
                        Started by briansaul, Today, 05:31 AM
                        0 responses
                        9 views
                        0 likes
                        Last Post briansaul  
                        Started by traderqz, Yesterday, 12:06 AM
                        11 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Working...
                        X