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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X