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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      51 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      275 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X