Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Order rejected
Collapse
X
-
The problem still remains, how will the script detect that it needs to send this order?The order would be submitted to the account with <Account>.CreateOrder() and <Account>.Submit().
Comment
-
Yes, exactly. Thank you!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.
Comment
-
Thanks Chelsea. I tried that one with no luck, but I could have made a mistake. I'll go back and check that revision.
Comment
-
Me again, thanks for your patience
I'm stuck here, getting errorname.cs No overload for method 'CreateOrder' takes 8 arguments CS1501 131 36 Code: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; break; } } } if (stopOrderRejected) { double limitPrice = Position.AveragePrice - 10 * TickSize; Order newLimitOrder = myAccount.CreateOrder(myInstrument, OrderAction.Sell, OrderType.Limit, 0, limitPrice, 0, TimeInForce.Day, "NewLimitOrder"); Account.Submit(new[] { newLimitOrder }); }
Comment
-
The syntax of CreateOrder is:
CreateOrder(Instrument instrument, OrderAction action, OrderType orderType, OrderEntry orderEntry, TimeInForce timeInForce, int quantity, double limitPrice, double stopPrice, string oco, string name, DateTime gtd, CustomOrder customOrder)
As you can see, comparing this with your source above, some of your arguments are the wrong type and you are missing some others.
Check the documentation at https://ninjatrader.com/support/help...reateorder.htm for how to use this method.
Comment
-
Thanks. I feel like a child learning this stuff. I didn't realize I had to fill in all the parameters, so when I got that error the first time I started removing things. I had the oco string empty because it isn't an oco. changed it, compiled ok. Now to wait for some volatility to see if it works.
Comment
-
-
I updated to sring.Empty and still got the same error:
Is there something else I need to change in order to use that? I looked at your example for an add-on, and other than seeing that string.Empty was used to send an order, I didn't see anything else to compare.Code: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; break; } } } if (stopOrderRejected) { double limitPrice = Position.AveragePrice - 10 * TickSize; Order newLimitOrder = myAccount.CreateOrder(myInstrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Automated, TimeInForce.Day, 0, limitPrice, 0, string.Empty, "NewLimitOrder", Core.Globals.MaxDate, null); Account.Submit(new[] { newLimitOrder }); }
Comment
-
Hello OldHatNoobCoder,
You should not be using the Position.AveragePrice unless you have moved to using native strategy order methods. The Position object from the strategy will always be flat. It will not change if you are using Atm Strategy methods or placing orders directly to the account. I recommend that you remove that code from your script.
Also, the order cannot have a quantity of 0. Please change this to 1.
I've copied and pasted the two lines to create the order and submit the order. I removed the Position.AveragePrice and changed the quantity to 1, and I'm not seeing an error. Below is a link to a video of the test.
Can you reproduced with this exported test script on your end?
AccountOrderSubmitTest_NT8.zipChelsea B.NinjaTrader Customer Service
Comment
-
Thanks Chelsea, but that didn't affect the issue. Still got the error:
Also, I left it as zero based on this, on the page explaining this method:You can see it was sending the appropriate 1-contract size order with this setting (prior error message shared). And it was sending the order (or trying to), so I'm not sure why that change would have been necessary. If it's no different, I'd rather send the order at the more appropriate price, since close [0] gives me less control over price of the order.limitPrice Order limit price. Use "0" should this parameter be irrelevant for the OrderType being submitted.
Alas, tried it and didn't change things.Last edited by OldHatNoobCoder; 05-11-2023, 10:17 AM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
547 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
323 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
99 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
543 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
545 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment