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

Series<bool> causing error "index was outside the bounds of the array"

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

    Series<bool> causing error "index was outside the bounds of the array"

    I am having a strange issue with one of my Series<bool> objects where it causes the script to fail and displays the above error message. What's strange about it is that I have another script that I literally copy and pasted the code from that runs into no issues while calculating over the same data. The script also fails well into the data, i.e. on bar 4378.

    Code:
    private Series<bool> upTrend;
    then in state.config...

    Code:
    upTrend = new Series<bool>(this);
    onbarupdate...

    Code:
    upTrend[0] = (paradigms[0] == up4 || paradigms[0] == up2 && paradigms[1] == up4)  ?  true : false;
    Even in the same problematic script, I have two other series<bool> objects called noTrend and dnTrend that calculate with no issues whatsoever. They are not really different, they are just defined by a different order of the array paradigms[], and besides, the script runs if I comment out ONLY the line I wrote here above in onbarupdate.

    Any ideas? thanks

    #2
    Hello lunardiplomacy,

    Thank you for your post.

    What I'd suspect here is that somehow one of those series doesn't have something assigned on the bar you're looking at, causing the null reference error. I'd recommend adding prints to print the value of the paradigms[0] and paradigms[1] on each bar to see if one of those prints something strange when it throws the error.

    This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.



    If you run into issues like we saw here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess what is different between the two.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Irukandji, Yesterday, 02:53 AM
    2 responses
    17 views
    0 likes
    Last Post Irukandji  
    Started by adeelshahzad, Today, 03:54 AM
    0 responses
    3 views
    0 likes
    Last Post adeelshahzad  
    Started by CortexZenUSA, Today, 12:53 AM
    0 responses
    3 views
    0 likes
    Last Post CortexZenUSA  
    Started by CortexZenUSA, Today, 12:46 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by usazencortex, Today, 12:43 AM
    0 responses
    5 views
    0 likes
    Last Post usazencortex  
    Working...
    X