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 Taddypole, 04-26-2024, 02:47 PM
      2 responses
      14 views
      0 likes
      Last Post Taddypole  
      Started by futtrader, 04-21-2024, 01:50 AM
      6 responses
      58 views
      0 likes
      Last Post futtrader  
      Started by sgordet, Today, 11:48 AM
      0 responses
      4 views
      0 likes
      Last Post sgordet
      by sgordet
       
      Started by Trader146, Today, 11:41 AM
      0 responses
      5 views
      0 likes
      Last Post Trader146  
      Started by jpapa, 04-23-2024, 07:22 AM
      2 responses
      22 views
      0 likes
      Last Post rene69851  
      Working...
      X