Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bounds Array error

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

    Bounds Array error

    Hello,

    I converted my indicator to an strategy, not drawings or plots, just calculations. It is based on Volume.
    I'm getting the error OnBarUpdate method on bar 0: Index was outside the bounds of the array. The error is caused by the line "Value[0] = Instrument.MasterInstrument.InstrumentType == InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)Volume[0]) : Volume[0];" but if I remove it the strategy does not do the calculations in the logic.

    Please, could you help me?

    Regards,

    Marcos L.


    #2
    Hello superg3,

    Thanks for your post.

    You have two index references on that line, Value[0] and Volume[0]. I suggest printing those values on separate lines to see which is the bad index reference.

    Print("Values[0]: " + Value[0]);
    Print("Volume[0]: " + Volume[0]);

    If Value[0] is a bad reference you likely did not call AddPlot in the script.

    AddPlot - https://ninjatrader.com/support/help...s/?addplot.htm

    Please let me know if we can be of further assistance.

    Comment


      #3
      Hi Jim,

      the output is:

      Values[0]: 15
      Volume[0]: 15

      excuse me but I do not understand why would I call AddPlot, as I said in my first post in the strategy there is no drawings or plots, there is calculation logic only.

      Comment


        #4
        Some help please?

        Comment


          #5
          Hello superg3,

          Please note that our morning shifts can be busy with new inquiries and it may take a few moments to return to an open inquiry. Thanks for your understanding and patience.

          AddPlot is needed to make Values[][] or Value[] references. I have attached a video demonstration below.



          You can set PlotBrushes to Brushes.Transparent to make plots invisible. You can also create the Plot with a transparent Brush so it is invisible.

          PlotBrushes - https://ninjatrader.com/support/help...lotbrushes.htm

          Let me know if you have any questions.

          Comment


            #6
            Hello Jim,

            first excuse me, I'm in Europe and I forgot the time difference.

            In the other side, thank you for your clear explanation. Now my strategy is starting to work.

            Kind regards,

            Marcos L.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            41 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            64 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            41 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X