• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Index was outside the bounds of the array

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

    Index was outside the bounds of the array

    I load my indicator that is supposed to show various lines into a chart. The lines do not show. I press F5, then the lines show in the chart. But at the same time I am getting the error message in the Log and Trace files:
    Error on plotting indicator 'EMAHLines5240'. Please check the 'OnBarUpdate' or the 'Plot' method: Index was outside the bounds of the array.

    I thought that perhaps I had not loaded sufficient days in the DataSeries but even when I increased that to 350 days the same error message continues to show up.

    Would appreciate some help to figure out what am I doing wrong here.

    sandman
    Attached Files

    #2
    Hello sandman,

    Thanks for your post.

    I've loaded a CL 02-18 chart of 1-minute bars and the lines do not appear. I changed to 6 days loaded and the lines constantly show up. I have not seen the error reported. I've tried changing the setting to draw 20 bars in the future and no issues, 100 bars in the past and no issues. I've switched to ES, YM, NQ and again no issues with 6 days of 1-minute data.

    You might see if you can replicate on your end.

    If you do continue to experience errors, I recommend that you add print statements before each Draw line to see where the code stops that generates the error.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for checking Paul,
      All the trials you laid out had been done by me too. I.E. once the lines show in the chart, I can change around the settings as I wish but each time I change a setting, the lines first disappear, then I have to hit F5 and they show - and at the same time it logs that error message in the Log file. Switching from one instrument to another does not make them disappear.

      How do I go about adding "print statements before each Draw line to see where the code stops that generates the error"? I've never done that before.

      sandman

      Comment


        #4
        Hello sandman,

        Thanks for your reply.

        Here is a link to our debugging tips: https://ninjatrader.com/support/foru...ead.php?t=3418

        For your code, here is an example:

        Print ("Drawing 5m");
        DrawLine("5m", false, lline, (EMA(BarsArray[1],13))[0], -right5, (EMA(BarsArray[1],13))[0], neut, DashStyle.Solid, wline0);

        Print ("Drawing 15m");
        DrawLine("15m", false, lline, (EMA(BarsArray[2],13))[0], -right15, (EMA(BarsArray[2],13))[0], Color.Red, DashStyle.Solid, wline0);

        Print ("Drawing 30m");
        DrawLine("30m", false, lline, (EMA(BarsArray[3],13))[0], -right30, (EMA(BarsArray[3],13))[0], Color.Blue, DashStyle.Solid, wline0);


        Prior to loading the indicator, make sure you open the output window as that is where the print statements will appear, Tools>Output window.

        Also, any changes you make to your code, it is important to remove the indicator from the chart and then reapply the indicator to make sure you are working with a fresh instance that has your changes.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          I appreciate it - thank you. Adding the Print statement did not show up anything odd. Something must have crept in this version somehow somewhere. I say that now because I went back and build it totally anew from scratch. And that new version now works just fine with no error messages at all.

          sandman

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Arkadiy_B, Today, 06:43 AM
          0 responses
          2 views
          0 likes
          Last Post Arkadiy_B  
          Started by leontancfa, Today, 06:09 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by soulfx, 12-01-2017, 08:44 AM
          3 responses
          1,019 views
          0 likes
          Last Post NinjaTrader_EricB  
          Started by Parmenides48, 04-09-2019, 03:32 AM
          10 responses
          50 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by NinjaCustomer, Today, 01:48 AM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_EricB  
          Working...
          X