Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Index was outside the bounds in the array... Ok but...

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

    Index was outside the bounds in the array... Ok but...

    Hello
    I am trying to insert the ichimokucloud indicator (here: https://ninjatraderecosystem.com/use...indicator-nt8/) into my indicator.
    I can retrieve the different values ​​for the current bar without any problem, but as soon as I try to use the past bars I get an error even though I have 365 bars displayed and I make sure there are enough bars with if (CurrentBar < 27) return; to be sure that the indicator has been calculated at least once when I try to retrieve index 1
    I don't understand. Can you help me?
    Thank you​

    Code:
    protected override void OnBarUpdate()
            {
                 if (CurrentBar < 27) return; // S'assurer qu'il y a suffisamment de bars
    
                 int Trend = -1;
                
                 if (IchimokuCloud1.SenkouSpanA[0] > IchimokuCloud1.SenkouSpanB[0])
                 {
                     Trend = 1;
                 }
                
                 Values[2][0] = Trend;
                
                 if (IchimokuCloud1.SenkouSpanA[0] > IchimokuCloud1.SenkouSpanB[0] && IchimokuCloud1.SenkouSpanA[1] < IchimokuCloud1.SenkouSpanB[1] )
                 {
                      Values[3][0] = 0;
                 }
            }
    ​
    Last edited by noabai; 11-12-2024, 03:33 AM. Reason: Tradslated by google

    #2
    Hello noabai,

    Thank you for your post.

    I recommend debugging the script using prints so you can determine which line of code is throwing the error and why.

    For each condition, or any code that is accessing a collection/array/series, print the time, CurrentBar, and the index you are trying to access.

    For example,

    Code:
    Print(Times[0][0] + " CurrentBar: " + CurrentBar + " IchimokuCloud1.SenkouSpanA[0]: " + IchimokuCloud1.SenkouSpanA[0] + " > IchimokuCloud1.SenkouSpanB[0]: " + IchimokuCloud1.SenkouSpanB[0]);
    if (IchimokuCloud1.SenkouSpanA[0] > IchimokuCloud1.SenkouSpanB[0])
    {
    Trend = 1;
    }
    Please let us know if you need further assistance. ​
    Last edited by NinjaTrader_Gaby; 11-12-2024, 09:31 AM.

    Comment


      #3
      Thank you for your interest in my question but by restarting my PC and launching NT8 again, everything returned to normal...

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      637 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      572 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X