Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with Exit comands

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

    Problems with Exit comands

    Help please.
    Have code with 2 instruments NQ as main intrument + ES:
    Code:
    Add("ES 09-16", PeriodType.Minute, BarsPeriod.Value);
    Enter positions with:
    Code:
    if (Position.MarketPosition == MarketPosition.Flat &&
    								
    				(Closes[0][0] - EtN) > 0 &&
    				(Closes[0][0] - EtN) > 5		
    				)
    			{ 
    				if (BarsInProgress == 0)				
    				EnterShort(5, "NQ");						
    				
    				if (BarsInProgress == 1)
    				EnterLong(4, "ES");					
    			}
    And it's OK.
    I cant Exit them correctly:
    Code:
    if (BarsInProgress == 0)
    	{
            if (CrossBelow(XXXXX, 0, 1) || CrossAbove(XXXXX, 0, 1))
    				{	
    				//if (BarsInProgress == 0)
    				ExitLong("NQ");
    								
    				//if (BarsInProgress == 1)
    				ExitShort("NQ");
    					
    				}	
    	}
    			
    if (BarsInProgress == 1)
    	{
    	if (CrossBelow(XXXXXX, 0, 1) || CrossAbove(XXXXXX, 0, 1))
    				{
    				//if (BarsInProgress == 0)
    				ExitShort("ES");
    								
    				//if (BarsInProgress == 1)
    				ExitLong("ES");
    					
    				}
    	}
    Dont work.

    Code:
    if (BarsInProgress == 0)
    {
                                    if (CrossBelow(XXXXX, 0, 1) || CrossAbove(XXXXX, 0, 1))
    				{				
    				ExitLong();					
    				ExitShort();				
    				}	
    	}
    			
    if (BarsInProgress == 1)
    	{
    	if (CrossBelow(XXXXXX, 0, 1) || CrossAbove(XXXXXX, 0, 1))
    				{			
    				ExitShort();				
    				ExitLong();				
    				}
    	}
    Dont work.

    Noone Exits or 1 Exit and another is not.

    #2
    Hello iskip,

    Thank you for writing in.

    I want to note that your Exit methods need to be called on the same BarsInProgress of the instrument. You wouldn't be able to call an Exit method for the NQ when BarsInProgress is 1 as the NQ would be at BIP 0.

    To get around this, you'll want to use the Exit methods that accept a barsInProgressIndex parameter and enter the BarsInProgress index of the instrument you are trying to exit the position of.

    Code:
    ExitShort(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)
    ExitLong(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ZacharyG View Post
      Hello iskip,

      Thank you for writing in.

      I want to note that your Exit methods need to be called on the same BarsInProgress of the instrument. You wouldn't be able to call an Exit method for the NQ when BarsInProgress is 1 as the NQ would be at BIP 0.

      To get around this, you'll want to use the Exit methods that accept a barsInProgressIndex parameter and enter the BarsInProgress index of the instrument you are trying to exit the position of.

      Code:
      ExitShort(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)
      ExitLong(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)
      Please, let us know if we may be of further assistance.
      Do I correctly understand the code?
      Code:
      if (CrossBelow(EStoNQ(1).Plot0, 0, 1) || CrossAbove(EStoNQ(1).Plot0, 0, 1))
      							
      				{	
      				
      				ExitLong(0, 5, "",""); //for NQ with BIP = 0
      				ExitShort(0, 5, "","");				
      				
      				ExitLong(1, 4, "",""); //for ES BIP = 1 
      				ExitShort(1, 4, "","");
      					
      				}

      Comment


        #4
        Hello iskip,

        The sample you have provided will exit any open positions you have for both instruments if your condition is true.
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Spiderbird, Today, 12:15 PM
        0 responses
        4 views
        0 likes
        Last Post Spiderbird  
        Started by lorem, Yesterday, 09:18 AM
        3 responses
        13 views
        0 likes
        Last Post lorem
        by lorem
         
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        12 responses
        42 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        6 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X