Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to prevent Order Cancellation?

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

    #16
    Hello johnnybegoode,

    You can add a class level bool to the condition. Below would be how you can set that up using a bool called "SubmissionReached" that is initialized as false.

    Code:
    if (!SubmissionReached && YOUR OTHER ENTRY CONDITIONS)
    {
        SubmissionReached = true;
        // Order submission methods here
    }
    The submission will only occur once until the bool is flipped back.

    Then later in OnOrderUpdate when you assign the order, you can set the bool back to false:

    Code:
    if (order.Name == " YourOrderName")
    {
        YourOrderObject = order;
        SubmissionReached = false;
    }
    At this point the order object will no longer be null, so the entry condition will not become true again, but the bool will be reset so the next time the condition becomes true, it only becomes true once.

    We look forward to assisting.

    Comment


      #17
      Thanks.
      The boolean method works that it stopped exiting continuously
      but it is still submitting too fast.

      Strategy Exits more once and the other exits turned into entry when there should be none.
      (see attachment)

      *** Update:
      I switched SubmissionReached = false
      to after the OrderState.Filled and it
      seems to work for now...

      Code:
        if (entryOrder != null && entryOrder == order)
        {
            Print(order.ToString());
            if (order.OrderState == OrderState.Filled)
            {
                SubmissionReached = false;
                entryOrder = null;
            }
        }
      Attached Files
      Last edited by johnnybegoode; 02-19-2021, 09:44 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      479 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      323 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      258 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      342 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      311 views
      0 likes
      Last Post CarlTrading  
      Working...
      X