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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      128 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      73 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      116 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      109 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      88 views
      0 likes
      Last Post CarlTrading  
      Working...
      X