• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by webus, Today, 02:03 AM
    0 responses
    5 views
    0 likes
    Last Post webus
    by webus
     
    Started by momchi, Yesterday, 07:12 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by DieSlower, Yesterday, 11:02 PM
    0 responses
    5 views
    0 likes
    Last Post DieSlower  
    Started by gujungg, Yesterday, 10:59 PM
    0 responses
    12 views
    0 likes
    Last Post gujungg
    by gujungg
     
    Started by DieSlower, Yesterday, 09:46 PM
    0 responses
    13 views
    0 likes
    Last Post DieSlower  
    Working...
    X