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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      81 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      149 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      79 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      52 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      59 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X