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

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.
    JimNinjaTrader Customer Service

    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.
          JimNinjaTrader Customer Service

          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 Stanfillirenfro, Today, 07:23 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            2 responses
            21 views
            0 likes
            Last Post cmtjoancolmenero  
            Started by olisav57, Yesterday, 07:39 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by cocoescala, 10-12-2018, 11:02 PM
            7 responses
            944 views
            0 likes
            Last Post Jquiroz1975  
            Started by oviejo, Today, 12:28 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X