Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AtmStrategyChangeEntryOrder()

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

    AtmStrategyChangeEntryOrder()

    Hi,I am having trouble with canceling entry orders, the code below is submitting an entry order at each close after the first trade.


    I am using the AtmStrategyChangeEntryOrder() so that if i miss an entry, the entry order will be submitted on the next bar's closing price. But once a trade is filled i want it to cancel changing my entry order, any suggestions on how i can cancel
    AtmStrategyChangeEntryOrder() once an order is filled?

    Code:
    if(LongSetUp == true
                    &&     orderId.Length == 0 && atmStrategyId.Length == 0)
                    {
                        atmStrategyId = GetAtmStrategyUniqueId();
                        orderId = GetAtmStrategyUniqueId();
                        AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, Close[0], 0, TimeInForce.Gtc, orderId, "NQ",atmStrategyId);
                        AtmStrategyChangeEntryOrder(Close[0], 0, orderId);
                        //How to stop this from submitting an order after each close
                        //reset the longsetup once filled or keep chasing it
                            if (orderId.Length > 0)
                            {                
                                string[] status = GetAtmStrategyEntryOrderStatus(orderId);
                                // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
                                // Check length to ensure that returned array holds order information
                            if (status.GetLength(0) > 0)
                            {
                                
                                // If the order state is terminal, reset the order id value
                                if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                                {
                                LongSetUp = false;
                                AtmStrategyCancelEntryOrder(orderId);
                                
                                }
                            }
                            //reset it once order is "FILLED" not submitted
                            }
                    }

    #2
    Hello dawdler,

    Once the entry order has been placed, orderId.Length should be a non zero value. You may get better results placing it in the block indicated below, and you will also have to define your condition for
    so that if i miss an entry, the entry order will be submitted on the next bar's closing price.
    // Check for a pending entry order
    if (orderId.Length > 0)
    {
    AtmStrategyChangeEntryOrder(Close[0], 0, orderId);
    string[] status = GetAtmStrategyEntryOrderStatus(orderId);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your help Ryan. I placed AtmStrategyChangeEntryOrder() where u suggested, but i don't seem to be needing an condition for handling a missed entry, the code is automatically adjusting my entry order to next bar's close.Thanks again!

      Below is the corrected code for reference

      Code:
      if (orderId.Length > 0)
                  {
                      string[] status = GetAtmStrategyEntryOrderStatus(orderId);
                      AtmStrategyChangeEntryOrder(Close[0], 0, orderId);    
                      
                      if (status.GetLength(0) > 0)
                      {
                        
                          if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                              orderId = string.Empty;
                              ShortSetUp = false;
                              LongSetUp = false;
                      }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      639 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      572 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X