Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATM Strategy - Stuck in Pending

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

    ATM Strategy - Stuck in Pending

    This in SIM Mode so not urgent.

    I created a Strategy to use ATMStrategy methods. Randomly, maybe 1 out of 10 trades, either a Stop or Target gets stuck in Cancel Pending after the trade is closed.

    Qeustions

    1: What could be causing this? What should I look for? Isn't the ATM supposed to handle all these issues?
    2: How do I clear it out of the Orders Tab in Control Panel?

    Will not go live until all these little issues are cleaned up.
    Last edited by TAJTrades; 09-06-2023, 09:39 AM.

    #2
    Hello TAJTrades,

    Are you using AtmStrategyClose() to close the trade?

    To clear the orders, reset the Sim101.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      No.

      I am using AtmStrategyCreate() following the Help Guide.

      The ATM Strategy that is called is very simple.
      Order Quantity - 1
      Parameter Type - Ticks
      Stop Loss - 20
      Profit - 20
      Stop Strategy - None.


      Then I use AtmStrategyChangeStopTarget() to the correct Sup/Res prices. That seems to work flawlessly.
      Last edited by TAJTrades; 09-06-2023, 09:59 AM.

      Comment


        #4
        Question:

        If I reset the ATMStrategyID to string.Empty before the internal operation is complete, would that interfere with the internals of how NT handles the Cancel operation?
        Last edited by TAJTrades; 09-06-2023, 10:02 AM.

        Comment


          #5
          Hello TAJTrades,

          How is the trade closing? Is the limit or stop being filled?

          Are you attempting to change an order after it has been filled or cancelled?
          Is GetAtmStrategyStopTargetOrderStatus() showing the orders are still working?

          Assigning a new value to a string variable holding the AtmStrategyID would not actually change the id of the running Atm and would only effect trying to use AtmStrategy methods that need that ID.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            "How is the trade closing? Is the limit or stop being filled?"
            Yes, either the Stop or Target is hit. Then the remaining order (Stop or Target) randomly gets stuck in Pending State.

            "Are you attempting to change an order after it has been filled or cancelled?"
            After the Entry Order is filled then on the next OnPriceChange the Stop and Target are adjusted to Sup/Res Levels. No issues here as they are working as expected.

            "Is GetAtmStrategyStopTargetOrderStatus() showing the orders are still working?"
            That is what I am coding up right now. Have to change workflow because I reset the AtmStratedyID on the next OnPriceChange.


            Code:
            #region Check for Closed Trade.  If So reset variables    
                if(    ATM_Strategy_Id.Length > 0
                &&    Entry_Order_State == "Filled"  
                &&      GetAtmStrategyMarketPosition(ATM_Strategy_Id) == Cbi.MarketPosition.Flat)    
                {
                    Entry_Order_Bar                                 = -1;
                    Entry_Order_Position                          = "Flat";    
                    Entry_Order_Description                     = string.Empty;        //    OSC_L3_Long, OSC_L2, OSC_L1
                    Entry_Order_Average_Filled_Price     = -1;
                    Entry_Order_Filled_Quantity               = -1;
                    Entry_Order_State                               = string.Empty;
            
                    ATM_Strategy_Id                                 = string.Empty;
                    Entry_Order_ID                                   = string.Empty;
                    isAtmStrategyCreated                         = false;    
                    Is_InitialTarget_Adjusted                     = false;
                    Is_Initial_StopTarget_Adjusted            = false;
            
                    if(PrintBarInfo && State == State.Realtime)  Print(string.Format("  Entry Order Variables Reset      {0} ", Entry_Order_ID  ));
                }
            #endregion​



            Might take a day as I have to step out.

            Comment


              #7
              Here is an image showing a new Entry is working as expected except for the Pending Order from an earlier trade.



              Click image for larger version

Name:	NT Support Image.png
Views:	115
Size:	57.9 KB
ID:	1267761

              Comment


                #8
                Redesigned the entire strategy code flow. So, 12 trades and no issues. I am going to call it a "Me" error. However, I still don't know why the opposite order gets stuck in pending ( Target hit and Stop gets stuck in pending or Stop hit and Target gets stuck in pending). I will leave that for you to ponder.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                53 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                130 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                70 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                44 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                49 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X