What is default duration of limit orders if I do not exit at close?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Limit orders open
Collapse
X
-
Limit orders open
I want to cancel my limit orders with CancelOrder() command but want to validate first what orders are pending. How can I check the open (not yet executed) limit orders?
What is default duration of limit orders if I do not exit at close?Tags: None
-
Hello PaulZ,
Thank you for your note.
To check these you will need to save the order to an IOrder. This will also be needed to use CancelOrder().
With the IOrder you can check the state of the order.
For example:
In #region Variables
private IOrder myOrder = null;
In OnBarUpdate():
myOrder = EnterLongLimit(1, Low[0]-10*TickSize);
Where ever you are about to cancel the order:
if (myOrder.OrderState == OrderState.Accepted || myOrder.OrderState == OrderState.Working)
CancelOrder(myOrder);
Below is a link to the help guide on IOrder.
http://www.ninjatrader.com/support/h...nt7/iorder.htmChelsea B.NinjaTrader Customer Service
-
Hi ChelseaB,
Thank you for your suggestion. I found that I first need to add a filter:
if (MyOrder != null)
before the statement
if (myOrder.OrderState == OrderState.Accepted || myOrder.OrderState == OrderState.Working)
as MyOrder.OrderState gives an error for null.
Is that correct or am I missing something?
Further, if I do not cancel my order and do not exit at the close, how long will my limit order stay pending?
Comment
-
Hello,
Thank you for the question.
Yes you would need to check that the order is not null, in the chance that is is null it would have an error if you tried to check the order state of a null IOrder.
in general checking for null is a good idea when working with objects, in the help guide examples for OnExecution and OnMarketData you can see null orders are checked for as well.
I look forward to being of further assistance.
Comment
-
Hello,
Thank you for the question.
I wanted to check, on the order that was canceled after 1 bar, was this order submitted by a condition that only was true for 1 bar and then was no longer true?
If the order is not set LiveUntilCanceled = true, the order would last 1 bar and then cancel unless the condition that placed the order remained true or if there was another condition to re submit the order to keep it alive.
Can you please see if this is the case, if not can you provide some of the logic you are using for the order entry?
I look forward to being of further assistance.
Comment
-
Hello,
Thank you for the reply.
Was the condition that created this order still true on the next bar? If not I would suspect this got canceled because of that.
If the overall condition that you have this statement in is only true on 1 bar, the order would be submitted but not kept alive if the condition is no longer true on the next bar.
A working order would not be persisted across multiple bars unless it is either set to do so using LiveUntilCanceled, or if the condition that created it remains true so it can call the order method on each OnBarUpdate using the signal name to update the existing order.
I look forward to being of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment