Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit orders not submitting

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

    Exit orders not submitting

    I have a strategy that subscribes to the Account.ExecutionUpdate event. Inside the event handler, if OrderState=Filled, I submit profit target and stop loss orders. These orders are not submitting, and when I ran Order Trace, the reason for each was "This was an exit order but no position exists to exit." The OrderState is filled, but just prior to submitting the exit orders, I Print the PositionAccount object, and it is empty. I noticed the statementDate is different in the PositionAccount than it is in the ExecutionEventArgs, but not sure if that is the problem... I was expecting to see my open MES position in PositionAccount. When I look at the chart, there is an open position, and when I look at the Positions tab on the Control Center, I see the open position. How can I successfully submit these exit orders from within the event handler? Am I using the correct event? It was my understanding that the Execution event is preferred for launching exit orders, over the OrderUpdate event.

    ExecutionUpdate ExecutionEventArgs:

    executionId='cc12ba8c599e4af2b0d1a83bb85081de' account='Sim101' instrument='MES 12-24' exchange=Default price=6066.25 quantity=1 marketPosition=Long operation=Add orderID='72c42e9b2afb4aae820721492d1e67c1' time='12/10/2024 6:00:23 AM' statementDate='2024-12-10'


    ExecutionUpdate Event Handler Code:

    if(e.Execution.Order.OrderState==OrderState.Filled && e.Execution.Order.OrderAction==OrderAction.Buy)
    {
    Print("Position=" + PositionAccount.ToString());
    ExitLongStopMarket(dbStopPrice, "Stop");
    ExitLongMIT(dbTargetPrice, "Target");
    Print("EXITS SUBMITTED");
    }​


    PositionAccount.ToString():

    instrument='MES 12-24' account='Sim101' avgPrice=0 quantity=0 marketPosition=Flat statementDate='2024-12-09'


    Order Trace:

    12/10/2024 6:00:23 AM Strategy 'CustomCopyOrderParent/221206846': Entered internal SubmitOrderManaged() method at 12/10/2024 6:00:23 AM: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=0 LimitPrice=0 StopPrice=6054.25 SignalName='Stop' FromEntrySignal=''
    12/10/2024 6:00:23 AM Strategy 'CustomCopyOrderParent/221206846': Ignored SubmitOrderManaged() method at 12/10/2024 6:00:23 AM: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=0 LimitPrice=0 StopPrice=6054.25 SignalName='Stop' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
    12/10/2024 6:00:23 AM Strategy 'CustomCopyOrderParent/221206846': Entered internal SubmitOrderManaged() method at 12/10/2024 6:00:23 AM: BarsInProgress=0 Action=Sell OrderType=MIT Quantity=0 LimitPrice=0 StopPrice=6082.25 SignalName='Target' FromEntrySignal=''
    12/10/2024 6:00:23 AM Strategy 'CustomCopyOrderParent/221206846': Ignored SubmitOrderManaged() method at 12/10/2024 6:00:23 AM: BarsInProgress=0 Action=Sell OrderType=MIT Quantity=0 LimitPrice=0 StopPrice=6082.25 SignalName='Target' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'​

    #2
    Hello Elevator2TheTop,

    Below is a link to working examples, ProfitCaseStopTrailIndicatorExample and ProfitChaseStopTrailAddonExample, which demonstrate submitting a stop and limit when an entry order fills using the addon approach.


    I'm noting you are using native strategy methods (ExitLongStopMarket()). These will only be effective for entries made by the strategy instance.
    If you are trying to submit orders for manual entries or entries not made by the instance of the strategy, you will need to use the addon approach and submit the orders with Account.CreateOrder() and Account.Submit().
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Ok, using Account.CreateOrder() and Account.Submit() worked -- thank you Chelsea!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      65 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X