Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 gm7_forum, Today, 05:51 PM
          0 responses
          1 view
          0 likes
          Last Post gm7_forum  
          Started by cre8able, Today, 03:20 PM
          1 response
          9 views
          0 likes
          Last Post cre8able  
          Started by fiddich, Today, 05:25 PM
          0 responses
          3 views
          0 likes
          Last Post fiddich
          by fiddich
           
          Started by gemify, 11-11-2022, 11:52 AM
          6 responses
          804 views
          2 likes
          Last Post ultls
          by ultls
           
          Started by ScottWalsh, Today, 04:52 PM
          0 responses
          4 views
          0 likes
          Last Post ScottWalsh  
          Working...
          X