Set the 'Parameter type' to Price, set the price to 99999
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Order rejected
Collapse
X
-
-
Hello OldHatNoobCoder,
This is showing the limit was rejected due to the OCOID. To confirm you are not submitted the replacement order through the account correct?
If so, this is showing that even without submitting the order through the account the same error is occurring, and further shows with live orders your broker isn't rejecting orders that re-use OCOIDs from rejected/cancelled/filled orders and has different behavior than the Sim101 (or how NinjaTrader Brokerage works).Chelsea B.NinjaTrader Customer Service
Comment
-
-
I changed the ordering of GetAtmStrategyStopTargetOrderStatus() and I was able to produce this error:
Comment
-
Hello OldHatNoobCoder,
This occur typically occurs if this method is called before the entry order as filled and the Atm has become active. The warning in orange can be ignored if you are intentionally checking the stop and target status before the entry has filled and the Atm is active.Chelsea B.NinjaTrader Customer Service
Comment
-
Hmm. When I place it later, nothing at all happens.
Code:// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements if (status.GetLength(0) > 0) { Print("The entry order average fill price is: " + status[0]); Print("The entry order filled amount is: " + status[1]); Print("The entry order order state is: " + status[2]); // If the order state is terminal, reset the order id value if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected") orderId = string.Empty; } } // If the stop order has been rejected, submit a new sell order if (atmStrategyId.Length > 0) { bool stopOrderRejected = false; string[,] stopOrders = GetAtmStrategyStopTargetOrderStatus("STOP1", atmStrategyId); if (stopOrders.Length > 0) { for (int i = 0; i < stopOrders.GetLength(0); i++) { if (stopOrders[i, 2].ToString() == "Rejected") { stopOrderRejected = true; Print ("Stop order rejected mofo "); break; } } } if (stopOrderRejected) { double limitPrice = Close[0] - 10 * TickSize; Order newLimitOrder = myAccount.CreateOrder(myInstrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Automated, TimeInForce.Day, 1, limitPrice, 0, string.Empty, "NewLimitOrder", Core.Globals.MaxDate, null); Account.Submit(new[] { newLimitOrder }); } // If the strategy has terminated reset the strategy id else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat) atmStrategyId = string.Empty;
Comment
-
This occur typically occurs if this method is called before the entry order as filled and the Atm has become active. The warning in orange can be ignored if you are intentionally checking the stop and target status before the entry has filled and the Atm is active.Code:// If the order state is terminal, reset the order id value
Comment
-
Hello OldHatNoobCoder,
By 'place it later' do you mean you are calling the method later in time, or do you mean you are calling the method lower in the code? (An a new bar update would be later in time. lower in the code would be at the same time)
Before calling this are you checking that the GetAtmStrategyEntryOrderStatus() is returning as Filled?Chelsea B.NinjaTrader Customer Service
Comment
-
By 'place it later' do you mean you are calling the method later in time, or do you mean you are calling the method lower in the code?
Yes, just didn't paste that:
Code:string[] status = GetAtmStrategyEntryOrderStatus(orderId); // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements[QUOTE][/QUOTE]
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello Bruce,
You are referring to adding rejection handling logic to the SampleATMStrategy included with NinjaTrader?
Thank you for the suggestion. We will take this into consideration.
I also have these some questions:
1)
I tried to the code presented just here two paragraphs above on 05-11-2023, 08:54 AM and I tried different coding.
Basically I am never able to get any information with GetAtmStrategyStopTargetOrderStatus() no matter what I do. Whether the order gets rejected or the Stop and Target are active.
I always get
'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'f7772ba8541d43eaa993147ded0ec9df' does not exist
'GetAtmStrategyStopTargetOrderStatus' method error: ATM strategy ID 'f7772ba8541d43eaa993147ded0ec9df' does not exist or is already in a terminated state
I am unable to get any stop/target information and I did all possible PrintOuts. I see OldHatNoobCoder tried.
I followed your recommendation above and I suspect that the problem is that I should provide the stop order ID instead of the atmStrategyId received by AtmStrategyCreate. Is that the reason? and if so, how do I get the order ID of the stop and target to be able to query them?
In the documentation for GetAtmStrategyStopTargetOrderStatus() I don't see an example.
2) If I get the ATM stop rejected in very fast market the ATM dies leaving me with exposed open position. Maybe the easiest solution to be compatible with NinjaTrader and Rithmic is to use CreateOrder. Can you indicate me a forum's thread that shows a way to track multiple different orders with a strategy that uses CreateOrder()?
3) Can you also indicate where I can find a way to monitor the ATM and close open position that are left exposed without bracket?
Best,
GioLast edited by giogio1; 12-09-2024, 06:16 AM.
Comment
-
Hello Gio,
"I wander, has Ninjatrader then provided a Logic? I cannot find it anywhere."
Unfortunately, no, the SampleAtmStrategy example does not have logic to handle an order rejection.
"Basically I am never able to get any information with GetAtmStrategyStopTargetOrderStatus() no matter what I do. Whether the order gets rejected or the Stop and Target are active."
Please provide the print output showing the value of the isAtmStrategyCreated bool and the value of GetAtmStrategyEntryOrderStatus() (which requires supplying the entry order id).
"If I get the ATM stop rejected in very fast market the ATM dies leaving me with exposed open position. Maybe the easiest solution to be compatible with NinjaTrader and Rithmic is to use CreateOrder. Can you indicate me a forum's thread that shows a way to track multiple different orders with a strategy that uses CreateOrder()?"
Below is a link to examples, ProfitCaseStopTrailIndicatorExample and ProfitChaseStopTrailAddonExample that use Account.CreateOrder() and Account.Submit().
"Can you also indicate where I can find a way to monitor the ATM and close open position that are left exposed without bracket"
If an order submitted by an Atm is rejected, this would cause the Account.OrderUpdate event to update with the rejected order.
Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello Gio,
If an order submitted by an Atm is rejected, this would cause the Account.OrderUpdate event to update with the rejected order.
https://developer.ninjatrader.com/do...op/orderupdate
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by UsenKone, Today, 05:22 AM
|
0 responses
17 views
0 likes
|
Last Post
![]()
by UsenKone
Today, 05:22 AM
|
||
Started by saltminer, 07-07-2025, 01:43 PM
|
1 response
66 views
0 likes
|
Last Post
|
||
Started by idude, 07-08-2025, 05:06 AM
|
0 responses
30 views
0 likes
|
Last Post
![]()
by idude
07-08-2025, 05:06 AM
|
||
Started by music_p13, 07-05-2025, 11:33 PM
|
1 response
45 views
0 likes
|
Last Post
|
||
Started by gubbar924, 03-18-2018, 05:15 PM
|
43 responses
5,491 views
0 likes
|
Last Post
![]()
by ESMC377
07-05-2025, 03:15 PM
|
Comment