Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error: 'Index Outside the Bounds of the Array' on Calling 'OnBarUpdate' Method

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

    Error: 'Index Outside the Bounds of the Array' on Calling 'OnBarUpdate' Method

    Hello,

    My associate developed a MultiDivergence strategy for NT8 that places long and short trades based on the number of divergences. It runs perfectly on his VPS (Windows Server 2016). However, when I try to run it on my VPS (also Windows Server 2016, NT8 version 8.1.3.1, Microsoft Visual Studio Community 2022), it compiles fine but fails during execution

    When I enable the strategy on market replay data using the Playback feature, it stops itself and I get the following 2 error messages in the logs:

    06/07/2024 00:29:06 Default Strategy 'Divergence_A': Error on calling 'OnBarUpdate' method on bar 36288: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    06/07/2024 00:29:06 Default Indicator 'MultiDivergence': Error on calling 'OnBarUpdate' method on bar 36288: Index was outside the bounds of the array.

    This issue is puzzling because my setup is identical to my associate's: same VPS, data set, indicators, strategies, lookback period (200 bars), and days to load (20 days)... It works on his machine but not mine somehow.

    To debug this, I used Microsoft Visual Studio Community 2022. I managed to attach the NT8 process in the debug feature, as you can see there the debug interface pop up:


    Click image for larger version  Name:	image.png Views:	0 Size:	263.6 KB ID:	1309861

    So far everything is going well but when I try to enable the strategy on NT8 I get this message:

    Click image for larger version  Name:	image.png Views:	0 Size:	12.4 KB ID:	1309862

    Which just crash the NT8 app when I click on OK...

    So here's where I am stuck, I don't know how to handle this as I'm very new to C# and have basically zero knowledge at how to debug such things, how Agile.net works, how the dlls files works etc...

    I found out the references list applied to my strategy is this:

    Click image for larger version  Name:	image.png Views:	0 Size:	52.5 KB ID:	1309863

    But I don't know what to do with it and also idk which .dll makes the Agile.net "obfuscator" happen...

    The strategy uses ninZaRenko bars, but the error persists even with traditional candlesticks.

    I collaborated with my associate and a mentor who is an expert in NT8 development and C# to find a solution for this issue, but we reached a dead end...

    I'm feeling overwhelmed with these errors. Could you help me resolve the initial errors in the OnBarUpdate method and guide me on fixing the MVSC 2022 debug issue? I need this debug feature for future strategies as well.

    Thanks in advance for your assistance,

    H.
    Last edited by hstufgg; 07-05-2024, 09:32 PM.

    #2
    bump, really need help

    Comment


      #3
      Hello hstufgg,

      The messages you are seeing are general messages letting you know that there was a problem with one of the BarsAgo you had used. To get a better idea of what line is causing an error you could use Print statements in the scripts code to see where the script is failing. That is done my checking what the last output print was before you see the error. Once it is known what part of the loic is having a problem it would be more apparent what the fix will need to be.

      Regarding the error in visual studio, the error box shows agile.net which is protection software used by third party vendors to protect NinjaScript code. If you imported the item as a compiled assembly you won't be able to use visual studio to debug it. That may also be caused by other items you have imported,, I would suggest to do a clean install using the following steps to avoid having anything imported before testing.

      Use the following steps to do a clean user folder test.

      1. Exit NinjaTrader
      2. Open the Documents folder
      3. Rename the NinjaTrader 8 folder to NinjaTrader 8 Old
      4. Download the installer from https://account.ninjatrader.com/download
      5. Install the platform, this will create a new user folder.
      6. Open the platform and import any of the items that you need

      To revert back to your previous data use the following steps.

      1. Exit NinjaTrader
      2. Open the Documents folder
      3. Rename the NinjaTrader 8 folder to NinjaTrader 8 Clean
      4. Rename the NinjaTrader 8 Old folder to NinjaTrader 8

      NinjaTrader looks for the folder named NinjaTrader 8 for your user data.​

      Comment


        #4
        Hello aligator,

        I don't see that the original poster in this thread mentioned anything about min/max, are you working with the original poster in some way? If not I would suggest making a new post if you had some kind of issue with using MIN or MAX or questions so that we can continue to assist with the original question here.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        566 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X