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; // 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 stafe, Today, 12:34 PM
    2 responses
    20 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by asmmbillah, Today, 11:18 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by nickse2003, Today, 09:56 AM
    1 response
    27 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by ATMtrader0001, Today, 10:08 AM
    5 responses
    37 views
    0 likes
    Last Post ATMtrader0001  
    Started by WHICKED, Today, 09:47 AM
    1 response
    26 views
    0 likes
    Last Post NinjaTrader_Spencer  
    Working...
    X