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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      55 views
      0 likes
      Last Post CarlTrading  
      Working...
      X