Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to break to the next if statement?

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

    How to break to the next if statement?

    I am trying to figure out how to break out of a nested if statement and going to the next if statement. EG:-

    Code:
    if(this.indPivAverage.ExtrnTrend[0] == 1 && lPiv != 0 && tsall == false) // Bullish trend Long Trades
    					{	
    						
    						
    						if(	lPiv == pp && tspp == true || lPiv == s1 && tss1 == true || 
    							lPiv == r1 && tsr1 == true || lPiv == s2 && tss2 == true ||
    							lPiv == r2 && tsr2 == true || lPiv == s3 && tss3 == true)		// check for trading ban 
    							return; [COLOR="Red"]// WHAT CAN I USE HERE TO MOVE THE PROGRAM DOWN TO....[/COLOR]
    						
    
    						
    					
    						for(int a=0;a < strengthPiv;a++)
    							{
    								if(Lows[mBIP][a] > lPiv)
    								{
    									x++;
    								}
    								else
    								break;
    							}
    							
    						if( x == strengthPiv && Position.MarketPosition == MarketPosition.Flat
    							&& (pEntry == null || pEntry.LimitPrice != (lPiv + entryAllowance))
    							&& oscSignalLong == true && lPiv != r3)	
    							{
    
    								pEntry = EnterLongLimit(0,true, 1, Math.Max(lPiv + entryAllowance * TickSize, lPiv + (hPiv - lPiv)*0.25), "pEntry");
    								
    								longLimit = lPiv;
    								
    							}	
    							
    						x = 0;
    							
    					}
    					
    if(this.indPivAverage.ExtrnTrend[0] == -1 && hPiv != 9999 && tsall == false) // [COLOR="Red"]HERE[/COLOR]

    I cant use return as it then skips other other logic I need processed.

    #2
    Hi GKonheiser,

    I am uncertain of what you are trying to do.

    I think you should just use an empty pair of brackets if you don't want that if to do anything when true.

    For example:

    Code:
    if(lPiv == pp && tspp == true || lPiv == s1 && tss1 == true || 
    	lPiv == r1 && tsr1 == true || lPiv == s2 && tss2 == true ||
    	lPiv == r2 && tsr2 == true || lPiv == s3 && tss3 == true)
    { }
    If you do not want the next code to run when this is true, use an else or else if on the next condition.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by helpwanted, Today, 03:06 AM
    1 response
    12 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    9 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    387 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X