Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Recursion crashes NT

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

    Recursion crashes NT

    I'd appreciate it if someone can explain why the following code crashes NT. I posted this in General Development but haven't gotten any response. Maybe that's not the right place to post so I thought I'd try here.

    My coding skills are pretty rusty. Can someone find the error in the recursive method HighIn().

    Code:
    private int firstRun=0;
    
    protected override void OnBarUpdate(){
        if(firstRun<15){ firstRun++; return; }
        Print(HighIn(3));
    }
    private double HighIn(int bars){
        if(bars <= 2){ return High[bars]; }
        double value = HighIn(bars--);
        if(value>High[bars]){
             return value;
        }else{
             return High[bars];
        }
    }
    It compiles fine, but crashes NT when I try to run it in the strategy analyzer. I cannot find anything wrong with it.

    #2
    Hello Chippy,

    It looks like this is a duplicate of: https://ninjatrader.com/support/foru...od#post1188182

    I see a few answers have been provided in the other post, in the future please avoid duplicate posts.


    Please let me know if I can be of additional help.

    Comment


      #3
      Apologies Jesse. Feel free to delete this post. I wasn't sure if I had posted in the wrong place initially. Problem is resolved. Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      574 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X