Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
NTOrderStatus question
Collapse
X
-
Interactive Brokers
IB is the broker, but I think the other state is for when you place a limit order, and not stop limit.
T
-
Thanks, got it working . . .
Josh,
Thanks for your help, got it working. I have just one question that is confusing between your documentation and what I am seeing in testing.
Once the stop order is sent, it shows in NT as "Accepted" (Order confirmation received by broker). Would this status ever change to "Working" (Order confirmation received by exchange)?
I just need to know which states to code for.
Thanks again,
Thomas.
Leave a comment:
-
If your assumption is right (I do not know exactly) then you should be fine.
Leave a comment:
-
Think I got it . . .
Josh,
I think I am seeing what you are saying.
Change:
if (NTBuyMarket("order_id", 1) == 0)
to
if (NTBuyMarket(order_id, 1) == 0)
And all should work well. I was getting confused between the vars I was passing in and the quotes. I will let you know how my testing goes on Monday. Just let me know if you see any errors below:
function main() {
order_id=1000;
if (isLastBarOnChart() && NTConnected(1)) {
if (!orderPlaced) {
if (NTBuyMarket(order_id, 1) == 0) // buy 1 unit at market, assign order id (optionally)
orderPlaced = true;
stop_order_id=order_id+1;
stop_orderPlaced = true;
NTSellStop(stop_order_id, contract_num, buy_stop_level);
}
else {
// print some information on the current position and order
debugPrint("Position size: " + NTMarketPosition("") + "\r\n");
debugPrint("AvgEntryPrice: " + NTAvgEntryPrice("") + "\r\n");
debugPrint("OrderStatus: " + NTOrderStatus(order_id) + "\r\n");
debugPrint("StopOrderStatus: " + NTOrderStatus(stop_order_id) + "\r\n");
debugPrint("Filled #: " + NTFilled(order_id) + "\r\n");
debugPrint("AvgFillPrice: " + NTAvgFillPrice(order_id) + "\r\n");
debugPrint("RealizedPnL: " + NTRealizedPnL("") + "\r\n");
}
}
}
I assume even if my order_id's are INT in efs, they are treated as strings by the calls.
Regards,
Thomas.
Leave a comment:
-
Thomas,
The difference between "order_Id" was that that was never a variable. This is why you needed the quotes. When you did NTBuyMarket("order_id", 1) you used quotes so when you call the NTOrderStatus you use quotes also to match up the same order_Id name.
Because you now use NTSellStop(stop_order_id, contract_num, buy_stop_level) with stop_order_id being a string variable as opposed to simply being a string your stop's orderId is NOT "stop_order_id". It is whatever is contained inside that string.
So simply, to get NTOrderStatus() of your stop orders you need to type out the actual string of the stop order. If you did NTOrderStatus(stop_order_id) that will work to get your last stop order, but because you did this earlier stop_order_id=order_id+1; you will now need to decrement it to get your previous stop orders.
In fact, I think you may need to first declare your stop_order_id.
stop_order_id=order_id+1 <- I don't know what that line will do. When operating on strings the + just concatenates, it doesn't do math. You may be getting strings that look like 10001 or it may be confused by the 1 because thats not another string. stop_order_id = stop_order_id + "1" would work better in getting you unique ids. This way you get strings that look like 1000, 10001, 100011, 1000111.Code:var stop_order_id = "1000";
Last edited by NinjaTrader_JoshP; 09-19-2008, 02:45 PM.
Leave a comment:
-
OK, I will try . . .
Josh,
I understand the differences between using quotes and not, I was just following the examples that are provided with NT.
Also, if I do not need to use quotes, I just want to let you know the function works perfectly well for:
debugPrint("OrderStatus: " + NTOrderStatus("order_id") + "\r\n");
In my case, I am not using the strategy variable, nor am I using account, so in essence:
1. I need to get the default strategy
2. Pass that in with NTOrderStatus to get the stop order status?
If that is the case, why do I not have to do that with the regular order? Do you think you could just post an example in the same form of NTSample.efs that beginners could follow?
Regards,
Thomas.
Leave a comment:
-
NTOrderStatus("stop_order_id") is wrong. Your stop_order_id is a string variable. You don't need to use quotes. NTOrderStatus(stop_order_id)
Also, NTStopOrders("") <- you are missing the strategyId.
To get a list of the strategyIds you need to use NTStrategies(string account). Please see this article: http://www.ninjatrader-support.com/H...unctions1.html
NTStrategies() gets you strategyIds. NTStopOrders() gets you orderIds. NTOrderStatus() gets you the order status.
Leave a comment:
-
That doesn't work . . .
Josh,
This is what I am doing and neither of the calls are returning with data for checking the stop order status:
function main()
{
order_id="1000";
if (isLastBarOnChart() && NTConnected(1))
{
if (!orderPlaced)
{
if (NTBuyMarket("order_id", 1) == 0) // buy 1 unit at market, assign order id (optionally)
orderPlaced = true;
stop_order_id=order_id+1;
NTSellStop(stop_order_id, contract_num, buy_stop_level);
}
else
{
// print some information on the current position and order
debugPrint("Position size: " + NTMarketPosition("") + "\r\n");
debugPrint("AvgEntryPrice: " + NTAvgEntryPrice("") + "\r\n");
debugPrint("OrderStatus: " + NTOrderStatus("order_id") + "\r\n");
debugPrint("StopOrderStatus_1: " + NTOrderStatus("stop_order_id") + "\r\n");
debugPrint("StopOrderStatus_2: " + NTStopOrders("") + "\r\n");
debugPrint("Filled #: " + NTFilled("order_id") + "\r\n");
debugPrint("AvgFillPrice: " + NTAvgFillPrice("order_id") + "\r\n");
debugPrint("RealizedPnL: " + NTRealizedPnL("") + "\r\n");
}
}
}
I see the order accepted in NT, I just can not get the call returned to my EFS.
Let me know what I am missing . . .
T
Leave a comment:
-
Use NTStopOrders(string strategyId) to see if you are actually using the right orderId string for the stop.
Leave a comment:
-
NTOrderStatus not returning status of stop order
I am running on 6.5, and I am still not getting back the status of a stop order. I am assigning my stop order its own ID, and then launching a call to NTOrderStatus("my_stop_order_id"). This same call works for my_order_id.
Is there a work around? I just want to make sure that my stop is set.
Thanks again,
Thomas
Leave a comment:
-
Correct. However, NT 6.5 will provide a way to
a) get the order IDs of stop/target orders per ATM strategy
b) then call NTOrderStatus for these order IDs
NT 6.5 first beta will be available in ~ 2 weeks.
Leave a comment:
-
NTOrderStatus question
In an earlier thread touching on a similar topic, it was said:
"You can not retrieve order id values of ATM strategy generated stop/target orders."
Does this also mean that the status of ATM strategy generated stops and targets cannot be acquired through the ATI?
I am trying to determine in a 2 stop 2 target strategy, whether a change of position is due to the target being hit, or the stop being triggered.
Any suggestions on how to do this?
Thanks.Tags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
14 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
119 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
172 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
88 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
131 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|

Leave a comment: