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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      93 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      138 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      123 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      73 views
      0 likes
      Last Post PaulMohn  
      Working...
      X