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 rdtdale, Today, 01:02 PM
    0 responses
    1 view
    0 likes
    Last Post rdtdale
    by rdtdale
     
    Started by alifarahani, Today, 09:40 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by RookieTrader, Today, 09:37 AM
    4 responses
    18 views
    0 likes
    Last Post RookieTrader  
    Started by PaulMohn, Today, 12:36 PM
    0 responses
    7 views
    0 likes
    Last Post PaulMohn  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    41 views
    0 likes
    Last Post love2code2trade  
    Working...
    X