Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Cancellation rejected by the Order Management System
Collapse
X
-
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.
-
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), "", "");
}
}4 PhotosTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
53 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
33 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
5 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
6 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Leave a comment: