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

Cancelled pending exit order, since associated position is closed

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

    Cancelled pending exit order, since associated position is closed

    Hello,

    For each executed entry buy LMT i send exit sell LMT,

    ENTRY level 0 | 2042.75 --- EXIT level 0 | 2043.25
    ENTRY level 1 | 2042.25 --- EXIT level 1 | 2042.75

    Buy entry:
    Code:
    OrderE=EnterLongLimit(0,true,qty, price, "entry"+i);
    Sell exit:
    Code:
     ExitLongLimit(0,true,qty,price,"exit"+i) ;
    Can you please tell me why I have this error message when i send my Sell?:

    2016-05-24 4:26:46 AM Strategy '75543177/MyTest: Cancelled pending exit order, since associated position is closed, orderId='dd61c326c3054f348fd9c88261895e17' account='Sim101' name='exit0' orderState=Working instrument='ES 06-16' orderAction=Sell orderType='Limit' limitPrice=2049.75 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=830 gtd='2099-12-01'
    Last edited by soma8; 05-24-2016, 04:05 AM.

    #2
    Hello soma8,

    Thank you for writing in.

    The ExitLongLimit() method you have provided should not be able to compile, as the overload you are attempting to use asks for six parameters and you have provided only five.

    Can you please clarify all the parameters you are using for your ExitLongLimit()?

    Additionally, do you have any other exit calls in your script that may be exiting your long position before it can be exited by ExitLongLimit()?
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks alot, appreciate your looking into this.
      In first time i had 5 entry Buy LMT, after a few seconds, the Entry0 was executed (the other orders in status Working), so I launched the first Exit0 LMT. then the entry1 was executed I launched the Exit1 (3 Entry buy, 2 Exit sell in status Working), when a Exit1 was executed I noticed that exit0 is canceled immediately.
      Error:
      2016-05-24 4:26:46 AM Strategy '75543177/MyTest: Cancelled pending exit order, since associated position is closed, orderId='dd61c326c3054f348fd9c88261895e17' account='Sim101' name='exit0' orderState=Working instrument='ES 06-16' orderAction=Sell orderType='Limit' limitPrice=2049.75 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=830 gtd='2099-12-01'

      [CODE
      protected override void OnStateChange(){
      if (State == State.SetDefaults){
      Description = @"MyTest";
      Name= "MyTest";
      Calculate= Calculate.OnBarClose;
      EntriesPerDirection= 1000000000;
      EntryHandling= EntryHandling.AllEntries;
      IsExitOnSessionCloseStrategy= false;
      SetOrderQuantity=SetOrderQuantity.Strategy;
      ConnectionLossHandling=ConnectionLossHandling.Reca lculate;
      IsFillLimitOnTouch = false;
      MaximumBarsLookBack= MaximumBarsLookBack.Infinite;
      OrderFillResolution= OrderFillResolution.Standard;
      Slippage= 0;
      StartBehavior= StartBehavior.ImmediatelySubmit;
      TimeInForce= TimeInForce.Gtc;
      TraceOrders = true;
      RealtimeErrorHandling= RealtimeErrorHandling.IgnoreAllErrors;
      StopTargetHandling= StopTargetHandling.PerEntryExecution;
      BarsRequiredToTrade= 10;
      DisconnectDelaySeconds=100;
      IsUnmanaged = false;
      ClearOutputWindow();
      }
      }
      protected override void OnMarketData(MarketDataEventArgs marketDataUpdate){
      for(int i=0;i<10;i++){
      EnterLongLimit(0,true,qty, price, "entry"+i);
      }}
      protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity, Cbi.MarketPosition marketPosition, string orderId, DateTime time){
      if (execution.Order.Name.Contains("entry"+i)==true && execution.Order.OrderState == OrderState.Filled){
      ExitLongLimit(0,true,qty,price,"exit"+i,"") ;
      }
      }
      ][/CODE]

      Comment


        #4
        Hello soma8,

        You are not tying your ExitLongLimit() to a specific entry order. When using an empty string for the "fromEntrySignal" parameter, it will attach that one specific ExitLongLimit() call to all entries.

        You will need to ensure that your ExitLongLimit() is being tied to each of your specific entries.

        Please take a look at this help guide link for more information about ExitLongLimit(): http://ninjatrader.com/support/helpG...tlonglimit.htm
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Thanks, now it's working

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mgco4you, Today, 09:46 PM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by wzgy0920, Today, 09:53 PM
          0 responses
          4 views
          0 likes
          Last Post wzgy0920  
          Started by Rapine Heihei, Today, 08:19 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Rapine Heihei, Today, 08:25 PM
          0 responses
          6 views
          0 likes
          Last Post Rapine Heihei  
          Started by f.saeidi, Today, 08:01 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X