Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Time of entry
Collapse
X
-
Hi frslvr, thanks for posting.
For historical data, you can save the value of Time[0] before or after the entry line e.g.
DateTime entryTime = Time[0];
EnterLong();
For real time, you can save the DateTime.Now variable within OnOrderUpdate to capture the system time when the order is filled.
Another way to get this would be to use BarsSinceEntryExecution and then use that bar number in Time[] to get the proper index.
Kind regards,
-ChrisL
-
Hi Chris,
Thank you for your reply.
I actually want to create an add-on displaying timer of how long the current trade is active. I thought there might be a property somewhere at account.Positions.
Ideally, I would like to use something like account.Positions[0].Time
Maybe you could suggest some other workaround?
Thanks
Comment
-
Hi frslvr, thanks for your reply.
Note that the Account.Executions collection is erased every after every market session. There is no supported NinjaScript code to get historical execution data from the database. The best way to ID an execution is from the Execution.OrderId property. Assuming your script was running at the time the trade was placed it can capture execution data from the Account.ExecutionUpdate event, write it to a .json file, and load the data when NinjaTrader starts up. The purpose of all this would be to cover the case where you enter a trade, close out of NinjaTrader, then need the addon to pick up from where it left off on the next startup. If you are only interested trades made in the current session the addon can subscribe to ExecutionUpdate and all the data including a timestamp will be available.
Best regards,
-ChrisL
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
647 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
368 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 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
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment