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.
    JesseNinjaTrader Customer Service

    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 burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      14 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,983 views
      3 likes
      Last Post jhudas88  
      Working...
      X