Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Index was outside the bounds of the array

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

    Indicator Index was outside the bounds of the array

    I took the Squeeze Momentum indicator from the app-share and seperated the data calculation into another file to be hosted by another indicator where it will be plotted. I plan to make it a Multi-Timeframe functionality but that is beside the point. In the original code
    Code:
              LengthBB = 20;
              MultBB = 2;
              LengthKC = 20;       // In the State.SetDefaults
              MultKC = 2;​
              
    
              iMinBar = Math.Max(LengthBB, LengthKC) + 1;   // In the State.Configure
    
    
              if (CurrentBar < iMinBar) return;  // In OnBarUpdate
    This seems to work and at first I tried to set this as a property that the hosting indicator could access to determine if the criteria has been met to continue. It didn't work I think I got the same as what is happening now where I basically do the same calculation via iMinBar= Math.Max(smi.LengthBB, LengthKC) + 1; However this produces Index was outside the bounds of the array.

    I have printed some outputs as follows:
    Code:
        Print(string.Format("Min bar: {0}", minBar));
        Print(string.Format("Current bar: {0}", minBar));
        Print(string.Format("SMI length: {0}", _smiLow.Count.ToString()));​
    My output is as follows:

    Min bar : 21
    CurrentBar: 21
    SMI Length: 5484

    And the indicator is not plotting

    #2
    Hello Itachi,

    From the error alone it would not be possible to see what the problem is, what is the specific line having the error when you have the error?

    Comment


      #3
      This is all I get from the output

      Indicator 'RinneganMT': Error on calling 'OnBarUpdate' method on bar 21: Index was outside the bounds of the array.

      It compiles fine there is no error in the Script Editor

      Comment


        #4
        Hello Itachi,

        that means some index you are using is not valid. Did you try to debug the code? You can use Print statements to trace what line is having a problem.

        Comment


          #5
          I commented out all State.Configure code, all State.DataLoaded code and commented out all OnBarUpdate code and I still get the same error

          Comment


            #6
            It was in the telemetry code

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X