Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancellation rejected by the Order Management System

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

    Cancellation rejected by the Order Management System

    I have a strategy that can close an order and at the same time send other in the opposite direction, for example, I can be short and I want to close the position at the close of a bar higher than the open but at the same time enter long in that same close, and every time it does It gets an error message "Cancellation rejected by the Order Management System" and what it does is open twice the position in the opposite direction of that new order, in the same example, It can be short with 4 contracts and at the moment when it close the position, It opens a long, but for 8 contracts, but nevertheless it is looks that the first short does not close.
    I understand that I do not violate any Internal Order Handling Rules since I exit the operation with ExitLong () or ExitShort ()
    Could you help me solve how to properly close the original position so on the reverse it does not open the double of contracts?
    Thank you
    This is the code
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1
    || CurrentBars[1] < 0)
    return;

    // Set 1
    if ((Momentum1[0] < 0)
    && (ATRenTicks1[0] >= Rango)
    && (ATRenTicks1[0] < Rango_Max)
    && (Close[1] > Open[1])
    && (Close[0] < Open[0]))
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if ((Momentum1[0] > 0)
    && (ATRenTicks1[0] >= Rango)
    && (ATRenTicks1[0] < Rango_Max)
    && (Close[1] < Open[1])
    && (Close[0] > Open[0]))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 3
    if ((Position.MarketPosition == MarketPosition.Short)
    && (CrossAbove(Close, Open, 1)))
    {
    ExitShort(Convert.ToInt32(Position.AveragePrice), "", "");
    }

    // Set 4
    if ((Position.MarketPosition == MarketPosition.Long)
    && (CrossBelow(Close, Open, 1)))
    {
    ExitLong(Convert.ToInt32(Position.AveragePrice), "", "");
    }

    }

    #2
    Hello jeremy8384,

    Thanks for your post.

    I would first suggest using Signal Names so you can more easily identify which orders are affecting how the positions are entered and exited.

    Your logic still may be calling Enter/Exit on the same bar. You can test with the Exit behavior removed to confirm if the Exit behavior is causing the issue.

    I may then suggest adding a bool to the strategy so you can better control the logic.

    Once the bool is created in Inputs and Variables, create a new condition set in Conditions and Actions that does not have any conditions. This should be Condition Set 1. In this Condition Set, create an action that sets the bool to true. This will be done on each bar that the strategy processes, before the rest of the logic is processed.

    In your entry/reversal condition sets, set the bool to false.

    In your Exit condition sets, check if the bool is true before allowing the Exit to take place.

    This will ensure that these methods are not called on the same bar.

    We look forward to assisting.

    Comment


      #3
      If you still have not found any solution then you might want to try adding additional checks in your code to ensure that the position has been closed before entering into a new one. For example, you could add a check to see if the position is no longer held before entering into a new long or short position. Another alternative you might want to consider is to use a CRM software like Planfix CRM, which can help you with order management, also it can provide you with features like order tracking, order history, and order analytics that can help you better manage your orders.
      Last edited by JosephDavidsona; 01-27-2023, 04:45 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      71 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      143 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      76 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      47 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      51 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X