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 outside the bounds of array problem.

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

    Index outside the bounds of array problem.

    Hi there,

    I am having a problem with one of my strategies which I just cannot seem to be able to solve. I've looked up previous "Index was outside the bounds of the array" issues and seen how it's supposed to be fixed with using ...

    if ( CurrentBar < 1)
    {
    return;
    }

    However sadly it is just not happening. Can anyone look at my code to see what may be going on? Thanks!

    Here is the pastebin code for it. https://pastebin.com/uxFnM37U

    #2
    Hello clubfoot,

    Thank you for writing in.

    If you use the following to ensure each series has enough bars,
    Code:
    if (CurrentBars[0] < 5 || CurrentBars[1] < 5 || CurrentBars[2] < 5)    return;
    Does your script run without error?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Sadly it still didn't it's still showing

      Strategy 'FPOrderFlowAuto': Error on calling 'OnBarUpdate' method on bar 5: Index was outside the bounds of the array.

      Comment


        #4
        Hello Clubfoot,

        Please upload a copy of the strategy in the following format so I may import and test on my end,

        To export a NinjaScript from NinjaTrader 8 do the following:
        From the Control Center window select Tools -> Export -> NinjaScript...
        Click Add>Select the indicator>OK>Export.
        Then attach that file you saved; under My Docs>NT8>Bin>Custom>Select the downloaded .zip file.

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hi Alan,

          Thanks for looking into this for me! Here it is
          Attached Files

          Comment


            #6
            Hello Clubfoot,

            I was able to compile and run the strategy without error with just 1 bar check, for example,
            Code:
            	if (CurrentBars[0] < 10) return;
            I have attached the revised strategy.

            Please let us know if you need further assistance.
            Attached Files
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              The problem is it starts up fine, but once it is supposed to do a condition it immediately says Index was outside the bounds of the array again and disables itself. Can you run it in playback and see if thats happening for you?

              Comment


                #8
                Originally posted by clubfoot View Post
                The problem is it starts up fine, but once it is supposed to do a condition it immediately says Index was outside the bounds of the array again and disables itself. Can you run it in playback and see if thats happening for you?
                That is because your issue here has nothing to do with the CurrentBars or any bars Array. Your message is telling you that you are trying to refer to an index in an Array, where the index does not exist.

                You have referenced and tried to populate the Values[] array by declaring 3 public Series<double>, but you never created the Values[] array, so any reference to that array will cause you grief. The Values array is indirectly created when you AddPot(). You have not added any Plots, but you are trying to populate the array that holds the values that the Plots reference.

                Either unhitch your public Series<T> from the Values[] array, or else declare the necessary Plots to create the Values[] array.
                Last edited by koganam; 08-26-2017, 09:36 PM. Reason: Corrected spelling.

                Comment


                  #9
                  Hi there,
                  I am facing the below similar error when launching NT8 and would like to know what might be some of the simplest ways to troubleshoot this given that I don't know much programming and have tried the below so far:
                  Re-starting my computer, clicking ok/ closing/ leaving the alert on but NT8 would shut itself down after a while for all cases.
                  Keep in mind that I can't even launch NT8 at this point and that I have not modified the codes before and am using some ready indicators from my provider.

                  Thank you guys in advance for your help!

                  Comment


                    #10
                    Welcome to the forums, kuokzhiqiang!

                    I have removed the other post from the other thread so there are not multiple people answering the same question.

                    The error may be caused by a custom script on the platform that is trying to request data or possibly from a custom BarsType. I would suggest taking the following steps to troubleshoot further. The advise in this thread would address different indexing related programming errors where a script developer would need to take debugging steps to see how their code hits that error.

                    1. Update the platform https://ninjatrader.com/PlatformDirect
                    2. Temporarily remove your workspaces to see if the issue is caused from a component in your workspace
                    3. If issues persist, I would like to you to contact me over email so we can keep this thread on topic.

                    Blank Workspace Test

                    Please follow the instructions below to test with a blank workspace.
                    • Shut down NinjaTrader
                    • Navigate to (My) Documents\NinjaTrader 8\workspaces
                    • Move your workspaces to a safe folder on your desktop and restart NinjaTrader
                    • Once NinjaTrader has started on just the control center, please open a new chart with no custom bar types/indicators/templates and test for issues.
                    • If there are no issues on this new workspace, please close NinjaTrader and bring your workspaces back in. If this reintroduces issues, we should then take a Top-Down or Bottom-Up approach to troubleshoot your workspace.
                    For a Bottom-Up Approach, I would suggest rebuilding the workspace, keeping track of each change made. It is often easier to rebuild your workspace one chart at a time with changes in groups. Once the issue returns, please remove the last group of changes made and test those individually for issues. Please reach out to the developer of any 3rd party plugin and report the issue and how you are able to encounter it so they can work to fix the issue.

                    For a Top-Down Approach, I would suggest making a backup of your workspace, and then to remove components sequentially until functionality is restored. Once functionality is restored, you can then re-import your 3rd party plugins in groups and test for issues. If an issue returns, please remove the last group of plugins removed and retest that group individually to identify an issue with a specific plugin. Please provide the developer of the plugin information on how they can recreate the issue on their end so they can work to fix the matter.

                    If you are seeing this issue with standard NinjaTrader components with the blank workspace test, please email me at platformsupport [at] ninjatrader.com with the text "Attn Jim 2460137" and please also include your log and trace files.

                    Attaching Log and Trace files

                    The steps below can be followed to attach your log and trace files to an email to our support address. Do not post your log and trace files here as they can contain personal information.
                    • Open your NinjaTrader folder under My Documents.
                    • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
                    • Send the 2 compressed folders as attachments to an email to platformsupport [at] ninjatrader [dot] com.
                    • Once complete, you can delete these compressed folders.
                    I look forward to assisting.
                    JimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by elirion, Today, 01:36 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post elirion
                    by elirion
                     
                    Started by gentlebenthebear, Today, 01:30 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post gentlebenthebear  
                    Started by samish18, Yesterday, 08:31 AM
                    2 responses
                    9 views
                    0 likes
                    Last Post elirion
                    by elirion
                     
                    Started by Mestor, 03-10-2023, 01:50 AM
                    16 responses
                    389 views
                    0 likes
                    Last Post z.franck  
                    Started by rtwave, 04-12-2024, 09:30 AM
                    4 responses
                    33 views
                    0 likes
                    Last Post rtwave
                    by rtwave
                     
                    Working...
                    X