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