Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Time Limit on order.
Collapse
X
-
Time Limit on order.
Is there a way to limit the time an order is active in a automated ATM Strategy like the SampleAtmStrategy you guys created? I was wondering if it is possible to place an order based on a 1 min. bar chart but have it canceled if not filled after 10 seconds and then reset for the next 1 min. bar? I hope that make sense. I have it so that it cancels and places a new order every minute on a 1 min chart but it would be nice to have the option to have the order cancel earlier if not filled within a certain amount of time like say 10 sec. Thanks for your help.Tags: None
-
Thanks for getting back to me.
So if I have a variable labeled; TimeofOrderEntry= placed at the end of the order entry
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
TimeofOrderEntry=
}
What would I put after the = to get the current time?
Then do I insert the TimeofOrderEntry here
if(TimeofOrderEntry< ?&& (status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
{
AtmStrategyCancelEntryOrder(orderId);
atmStrategyId = string.Empty;
orderId = string.Empty;
}
and then how would I write the code to be the current time +the 10 sec offset. I know how to do tick offsets but I am not sure on the time offsets. Am I even close on any of this? Also do I need to put something like this private DateTime lastTimePlot = Cbi.Globals.MinDate; in variables to be able to access time?
I know I ask a lot but your help is much appreciated.
Comment
-
Hello cre8it8,
You can use DateTime.Now to capture the current time.
TimeofOrderEntry = DateTime.Now;
You can add 10 seconds to this time and make a comparison to current time. You need to use ToTime() to convert the date time format to an integer.
if (ToTime(DateTime.Now) >= ToTime(TimeofOrderEntry.AddSeconds(10))
This reference sample can help with manipulating date time objects:
Manipulating DateTime objects
Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
558 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment