Announcement

Collapse
No announcement yet.

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