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.
    Gaby V.NinjaTrader Customer Service

    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 Zek303, 10-20-2024, 06:17 PM
      4 responses
      63 views
      0 likes
      Last Post bltdavid  
      Started by jointkp1, Today, 01:11 PM
      0 responses
      8 views
      0 likes
      Last Post jointkp1  
      Started by warpinator, Today, 01:01 PM
      0 responses
      13 views
      0 likes
      Last Post warpinator  
      Started by C_Hardy, 11-28-2024, 05:44 PM
      9 responses
      66 views
      0 likes
      Last Post C_Hardy
      by C_Hardy
       
      Started by kellyboy, Today, 11:29 AM
      0 responses
      9 views
      0 likes
      Last Post kellyboy  
      Working...
      X