Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
DateTime.Now
Collapse
X
-
Hello,
Thank you for the question.
In NinjaTrader there is the ability to use c# standard DateTime.Now (computer time) or there is also the bars time or Time
If you are doing chart time comparisons you would want to use the Time object in NinjaTrader to ensure you are getting the correct times for the bar you are looking at.
The Current bars time in NinjaTrader is:
you can do comparisons with the Time object using integers by using ToTime or ToDayCode:Time[0]
Time is just a datetime object except it is a series which you can use a BarsAgo value with much like the rest of the Price data objects in NinjaScript.
I look forward to being of further assistance.
-
Look up ToTime(). The output is military time, albeit NT does not actually say so.Originally posted by FCatan View PostHi, I need to compare the current time (I'm assuming that's contained in DateTime.Now) to an integer field in the forma HHmmss (military format). How do I convert DateTime.Nowinto an integer to make that comparison. thank you!
Comment
-
Strategy delay by a couple of seconds
I see on session template that you cannot change the session to 09:30:04 for example... is there a way to do this in code?
if(ToTime(Time[0]) < 093004)
return;
doesnt work on my 390 minute chart based strategy.
Regards and thx for assistance.
Comment
-
Hello everington_f,
Thank you for your post.
There would not be a way to do this in the Session Manager. And when using Minute bars, the timestamp will always be to the minute.
You could add a 1 Tick series and then check against it. For example:
For information on multiple time frames in code please visit the following link: http://ninjatrader.com/support/helpG...nstruments.htmCode:if(ToTime(Times[1][0]) < 093004)
Comment
-
it was just an idea, I have a multi instrument strategy with ADD() 50 stocks... i just want to delay entry a couple of seconds until I am sure that all data is coming in..... i have found that if I fire it at 093000 some stocks trade as if it were yesterday... because the primary bar series is updating.. but other less liquid members of the list come on line a fraction later... and hence execute falsely.
Could i use
!Historical ? but how do i reference the bars in progress index for that?Last edited by elliot5; 07-10-2015, 10:05 AM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 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
548 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
549 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment