Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Failed to call method 'Initialize' for indicator

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

    Failed to call method 'Initialize' for indicator

    Hi,

    I'm stumped with a rather odd problem.

    My indicator runs fine, with no error messages when applied to charts.

    However, when I set it as one of the columns in Market Analyzer, the following error message appears in the Log:

    "Failed to call method 'Initialize' for indicator xxx: Object reference not set to an instance of an object."

    I'm really at a loss to explain why the error message only pops up when used in MA, but not when applied to charts. The indicator itself works fine (in both instances) as far as I can tell.

    Any suggestions?

    Regards,
    Nick

    #2
    Hi Nick,

    Do you have access to the source code of this indicator?

    You should be able to isolate this error message in the indicator to a single line just by removing/commenting out everything in the Initialize method.

    Once you've isolated the offending lines, we can look into why that particular call is failing in one environment and another the other.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Nailed it.

      This was the offending line of code, if any others were curious:

      if (Instrument.MasterInstrument.InstrumentType == InstrumentType.Stock && BarsPeriod.Id != PeriodType.Day)

      -Nick

      Comment


        #4
        Failed to call method 'Initialize' for indicator 'Correlation'

        Hello guys. I get this message when test indicator Correlation (http://www.ninjatrader.com/support/f...tid=-1&lpage=1)
        Failed to call method 'Initialize' for indicator 'Correlation': 'Add' method only accepts positive 'period' values, but was -1 Min

        I tried to run this in strategy in Strategy Analyzer with EOD data.

        Code:
        protected override void Initialize()
         {
        Add(MyInstrum2,PeriodType.Day,1);
        Add(Correlation(Closes[0],CorrelationType.Pearson,14,1,MyInstrum2));
        Correlation(Closes[0],CorrelationType.Pearson,14,1,MyInstrum2).Panel=3;
        Correlation(Closes[0],CorrelationType.Pearson,14,1,MyInstrum2).ScaleJustification=ScaleJustification.Right;
        ...............................
        if (Correlation(Closes[0],CorrelationType.Pearson,14,1,MyInstrum2)[0]>0)
        buy...

        Comment


          #5
          Hello alexstox,

          Thank you for your post.

          Likely the cause of this is the following line in the Correlation indicator:
          Code:
          Add(Symbol2, BarsPeriod.Id, BarsPeriod.Value);
          Using BarsPeriod.Id and BarsPeriod.Value in Initialize() can have unexpected results and it is not recommended to use these in the Initialize() method as the bars are likely to not have loaded fully in Initialize(). Please contact the developer of the indicator for further assistance.

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello alexstox,

            Thank you for your post.

            Likely the cause of this is the following line in the Correlation indicator:
            Code:
            Add(Symbol2, BarsPeriod.Id, BarsPeriod.Value);
            Using BarsPeriod.Id and BarsPeriod.Value in Initialize() can have unexpected results and it is not recommended to use these in the Initialize() method as the bars are likely to not have loaded fully in Initialize(). Please contact the developer of the indicator for further assistance.
            Patrick, what can I replace it with?

            Comment


              #7
              Hello alexstox,

              Thank you for your response.

              You could replace it with the direct information of the chart you plan to use it on. For example a 1 Minute chart: Add(Symbol2, PeriodType.Minute, 1);

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by chbruno, Today, 04:10 PM
              0 responses
              1 view
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              436 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              5 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              18 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by frslvr, 04-11-2024, 07:26 AM
              9 responses
              127 views
              1 like
              Last Post caryc123  
              Working...
              X