Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to tell program to "go to line .."?

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

    How to tell program to "go to line .."?

    Hi, after some conditions are met I would like to tell the strategy to go to the end and skip everything in between. How do I code this?
    Thanks

    #2
    Originally posted by Stem1 View Post
    Hi, after some conditions are met I would like to tell the strategy to go to the end and skip everything in between. How do I code this?
    Thanks
    Hi Stem

    The approach I can think of is this:

    Say you have 3 conditions, A, B, C as the ones, which, if met, would terminate the analysis of the current bar. In OnBarUpdate, make these your first set of conditions as follows:

    Code:
    if(A && B && C)
    
    {
    Actions... // if there are actions to take before the jump to the end
    [COLOR=Blue][B]return[/B][/COLOR];
    }
    
    [COLOR=Blue][B]else
    ...[/B][/COLOR]
    The 'else' ensures that the rest of the code is not acted on if the conditions A,B & C are met.

    This is similar to when to put:

    Code:
    if (CurrentBar < Period)
                    return;
    telling NT that if there aren't enough bars for the indicator(s) to work on, then 'return', i.e. terminate the analysis for that bar.

    Comment


      #3
      Hello Stem1,

      Thank you for your post and to Arbuthnot for answering.

      Arbuthnot is correct here. This is good way to have your code check for when you want to continue with the script or stop it here.

      Let me know if I can be of further assistance.
      Cal H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      331 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      550 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X