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; // WHAT CAN I USE HERE TO MOVE THE PROGRAM DOWN TO....
    						
    
    						
    					
    						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) // HERE

    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 Jeremytang, 07-14-2018, 06:45 PM
    21 responses
    439 views
    0 likes
    Last Post mav8rick  
    Started by LeonK, Yesterday, 09:26 PM
    1 response
    8 views
    0 likes
    Last Post bltdavid  
    Started by NicholasJoannette, Yesterday, 03:01 PM
    2 responses
    11 views
    0 likes
    Last Post NicholasJoannette  
    Started by rach1994, Yesterday, 12:20 PM
    1 response
    35 views
    0 likes
    Last Post bltdavid  
    Started by litamm89, Yesterday, 11:00 AM
    5 responses
    22 views
    1 like
    Last Post rafael_delima86  
    Working...
    X