Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancellation rejected by the Order Management System

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

  • NinjaTrader_Jim
    replied
    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.

    Leave a comment:


  • 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), "", "");
    }

    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by Renorail, Today, 01:05 AM
0 responses
6 views
0 likes
Last Post Renorail  
Started by NeverDownMoney, Yesterday, 08:06 PM
1 response
9 views
0 likes
Last Post NeverDownMoney  
Started by GauthamK, Yesterday, 07:38 PM
0 responses
13 views
0 likes
Last Post GauthamK  
Started by Czarek, Yesterday, 05:42 PM
1 response
5 views
0 likes
Last Post NinjaTrader_ShawnB  
Started by Hyper, Yesterday, 05:13 PM
0 responses
4 views
0 likes
Last Post Hyper
by Hyper
 
Working...
X