Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Out of range error

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

    Out of range error

    I keep getting a sporadic out of range error on bar 34 despite the following checks on my multi-instrument strategy;


    if(State == State.Historical)
    return;

    if (CurrentBars[0] < 11 || CurrentBars[1] < 11 || CurrentBars[2] < 11)
    return;

    if (CurrentBar < 3)
    return;

    The currentbar value is 34 and the largest barsago value anywhere in the script is [2].
    How is this possible? Regards to all

    #2
    Hello everington_f,

    The code you have provided does not show any indexes being called.

    So far we can see that if there are exactly 2 additional series, any index for a series should be able to call up to 11 bars back. If there is only 1 added series, or any series index more than 11 bars ago would cause an error.

    Do you have a short test script you can export that demonstrates the behavior?
    (This would only have the index being called along with the conditions you have posted, but without any other logic that is not highlighting the behavior)

    To export a NinjaTrader 8 NinjaScript do the following:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message

    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>


    Below is a link to the help guide on Exporting NinjaScripts.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I cannot send you the entire code. I am doing some testing and will come back to you. What code apart from the above after onbarupdate can I add to prevent this outof range error? how is it possible to get out of range errors with the checks that I mentioned above? Regards

      Comment


        #4
        Hello everington_f,

        We would not want the entire script as we cannot provide debugging services for you.

        (Though this thread will remain open for any community members that would like perform this service as a convenience to you)

        I am asking for you to create a short test script that demonstrates the behavior and export this.
        (This would only have the index being called along with the conditions you have posted, but without any other logic that is not highlighting the behavior)
        Importantly this would not contain any code that is not necessary to reproduce the behavior. I would expect only 2 or 3 lines of logic in the script.

        Its possible to get out of range by calling an index that doesn't exist. As an example, adding only 1 additional series would cause an index error with CurrentBars[2].

        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
        Last edited by NinjaTrader_ChelseaB; 02-09-2017, 12:03 PM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ok I shall try to narrow it down for you. Regards

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by love2code2trade, 04-17-2024, 01:45 PM
          4 responses
          31 views
          0 likes
          Last Post love2code2trade  
          Started by cls71, Today, 04:45 AM
          2 responses
          10 views
          0 likes
          Last Post eDanny
          by eDanny
           
          Started by proptrade13, Today, 11:06 AM
          0 responses
          4 views
          0 likes
          Last Post proptrade13  
          Started by kulwinder73, Today, 10:31 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by RookieTrader, Today, 09:37 AM
          3 responses
          15 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X