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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      62 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      134 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X