Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterShort stuck in Submitted order state.

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

    EnterShort stuck in Submitted order state.

    I'm using only simple market order commannds of EnterShort, EnterLong, ExitShort, ExitLong. Strategy logic controls when they are invoked. Below is a snippet of debug / trace of a recent execution of strategy on Sim against NQ using 1 minute candlesticks.:

    EnterShort at : 2024-05-15 10:26:00 AM at price 18531.25
    Strategy 'AlgoTEST/327195422': Entered internal SubmitOrderManaged() method at 2024-05-15 10:25:45 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='MyShort1' FromEntrySignal=''
    The most current order state is: Submitted

    EXIT SHORT at 2024-05-15 10:26:00 AM at price 18531.5 Entry Price WAS 0 High[0] > BollDefault.Middle[0] 18538.5 18520.9761904762
    Strategy 'AlgoTEST/327195422': Entered internal SubmitOrderManaged() method at 2024-05-15 10:25:45 AM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='ExitShort1' FromEntrySignal='MyShort1'
    Strategy 'AlgoTEST/327195422': Ignored SubmitOrderManaged() method at 2024-05-15 10:25:45 AM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='ExitShort1' FromEntrySignal='MyShort1' Reason='This was an exit order but no position exists to exit'
    The most current order state is: Accepted
    The most current order state is: Working
    The most current order state is: Filled

    I've bolded some key concern areas. My questions are:
    1. How / why might an order get stuck at Submitted and what can I do to identify and address this in strategy logic?
    2. ExitShort fired (which it likely shouldn't have given enter appears to not have completed). But a trace on Order using protected override void OnOrderUpdate suggests something went through order states right up to filled. If EnterShort didn't conclude, and Trace suggests ExitShort failed, how did order state get to "Filled".

    ADDITION: FYI, Just noticed Position.MarketPosition is Flat at the end of this.


    Help! And thank you.
    Last edited by cshox; 05-15-2024, 01:20 PM.

    #2
    Hello cshox,

    Thank you for your post.

    Are you testing this in real-time, or backtesting using the Strategy Analyzer?

    If you're not sure which order got to the "filled" status, I recommend also printing out the order.Name along with the state so you can see exactly which order is reaching the filled state.

    This will also help confirm if an order is getting stuck and if so, which order in particular. Once you know which orders you are actually printing the order state for, it will be easier to examine the logic and determine what steps need to be taken to correct the behavior.

    "This was an exit order but no position exists to exit"

    This message will appear when your strategy calls ExitLong or ExitShort but no position exists to exit. You can check the current strategy position by referencing the Position.MarketPosition. You might need to add checks for an actual position before calling ExitLong()/ExitShort().



    Please let me know if I can assist further. ​

    Comment


      #3
      Hi Gaby,
      This is running real-time against sim account.

      Added debug to OnOrderUpdate in addition to OnBarUpdate and Trace already in place. Looks like a timing issue because EnterShort and ExitShort both called at roughly the same time. I'll address that in logic.

      QUESTION: Hoping you can help with the following question: How did Market Position get back to Flat if the ExitShort was ignored? And more confusing, the Short is STILL ACTIVE even though Position says Flat. I had to manually close position and kill strategy to stop short.
      • Suggestions?

      Debug Output FYI
      ENTER SHORT : 2024-05-16 11:37:00 AM Close <= SMA : 18746.25 18746.31 stoch < avg : 62.14 78.9 High >= PrevBB : 18754.75 18752.64 CurrBB 18748 18753.64

      Strategy 'AlgoTEST/327330849': Entered internal SubmitOrderManaged() method at 2024-05-16 11:36:01 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='MyShort1' FromEntrySignal=''

      ORDER Name: MyShort1, From: , Action: SellShort, State: Submitted, Price: 0, Id: e896550c40304086994b3d23711224e3, Time: 2024-05-16 11:36:01 AM

      EXIT SHORT : 2024-05-16 11:37:00 AM High < BBMid 18748 18737.5595238095 stop loss 18746 Enter/Close 0 18746

      Strategy 'AlgoTEST/327330849': Entered internal SubmitOrderManaged() method at 2024-05-16 11:36:01 AM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='ExitShort1' FromEntrySignal='MyShort1'
      Strategy 'AlgoTEST/327330849': Ignored SubmitOrderManaged() method at 2024-05-16 11:36:01 AM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='ExitShort1' FromEntrySignal='MyShort1' Reason='This was an exit order but no position exists to exit'

      Position.MARKET POSITION is Flat

      ORDER Name: MyShort1, From: , Action: SellShort, State: Filled, Price: 18746.25, Id: e896550c40304086994b3d23711224e3, Time: 2024-05-16 11:36:01 AM

      Comment


        #4
        Hello cshox,

        Thank you for your response.

        From your output, it looks like your MyShort1 order fills only after your strategy submits the exit.

        ORDER Name: MyShort1, From: , Action: SellShort, State: Submitted, Price: 0, Id: e896550c40304086994b3d23711224e3, Time: 2024-05-16 11:36:01 AM

        Strategy 'AlgoTEST/327330849': Entered internal SubmitOrderManaged() method at 2024-05-16 11:36:01 AM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='ExitShort1'​
        ​​

        It seems that you may have your exit condition becoming true as soon as the entry condition is true, leading to this behavior. Or, you have defined the exit to be submitted while the entry is submitted which won't work with signal names being used. So as you mentioned, it is an issue with timing. You should see this behavior stop if you address this in the logic of your script.

        Please let us know if you have any further questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        41 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X