Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Convert current date to Julian Date
Collapse
X
-
Hello jkt1120,
While this would not be specific to NinjaScript and is a general C# inquiry, I have done a quick google search for you.
Chelsea B.NinjaTrader Customer Service
-
Hello jkt1120,
You should be able to copy the method suggested on stack overflow within the class of your script, and then supply the date to that.
Finding if a time stamp is 3 days earlier than the current date would not involve converting the time to Julian in any way.
Code:if (Time[0] <= Core.Globals.Now.AddDays(-3))
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello jkt1120,
Apologies, I overlooked this was for NinjaTrader 7 and not for NinjaTrader 8.
For NinjaTrader 7 you could use the general c# DateTime.Now.
Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.
Please note, NinjaTrader 7 is no longer in active development and we are no longer considering new feature requests or changes for NinjaTrader 7. Main development has shifted to our flagship platform NinjaTrader 8. This does mean updates from brokerages, data feeds, or operating systems that require an update in NinjaTrader will not be implemented in NinjaTrader 7 and may cause an interruption in service.
While there is not a set ETA for the complete discontinuation of NinjaTrader 7, we highly recommend transitioning to NinjaTrader 8 as soon as possible before NinjaTrader 7 reaches its end of life to prevent interruption of service.
Click below to download NinjaTrader 8.
Last edited by NinjaTrader_ChelseaB; 06-13-2022, 03:32 PM.Chelsea B.NinjaTrader Customer Service
Comment
-
Good morning Chelsea, I hate being such an idiot, sorry but its still not working (Remember it Ninjatrader 7 if that matters)
Strategy\JKTZones.cs The type or namespace name 'Core' does not exist in the namespace 'NinjaTrader' (are you missing an assembly reference?)
Comment
-
Hello again Chelsea, I got the statement " Time[0].Date > DateTime.Now.AddDays(-daysLookBack) " working in realtime, thank you, however I had to do some back testing with Replay and I guess the attribute .Now is picking up today's current date. Can this be programmed differently for Replay testing? Again thank you very much for your help :-)
Comment
-
Chelsea, I need to remove the time portion of date time to only have the Date. (Ninjatrader 7 Strategy)
When I Googled it "Stackoverflow" gave me this suggestion:
zoneDate = DateOnly.FromDateTime(DateTime.Now);
but I getting a compile error "the name "DateOnly" does not exist in the current context"
Can you advise please .... Jack
Comment
-
Hello jkt1120,
The code you posted is for a later version of C# which NinjaTrader does not use. To clarify are you still asking about getting a julian date or are you trying to use the PC clock and store that to a variable?
The DateTime objects in C# have a Date property:
Code:DateTime.Now.Date Time[0].Date
JesseNinjaTrader Customer Service
Comment
-
These may also be useful, particularly for the question as originally asked:- https://docs.microsoft.com/en-us/dot...with-calendars
- https://docs.microsoft.com/en-us/dot...tframework-4.8
Thanks.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by suroot, 04-10-2017, 02:18 AM
|
4 responses
3,021 views
0 likes
|
Last Post
by truepenny
Today, 08:01 AM
|
||
Started by Stanfillirenfro, Today, 07:23 AM
|
1 response
6 views
0 likes
|
Last Post Today, 07:37 AM | ||
Started by cmtjoancolmenero, Yesterday, 03:58 PM
|
2 responses
22 views
0 likes
|
Last Post Today, 07:24 AM | ||
Started by olisav57, Yesterday, 07:39 PM
|
1 response
9 views
0 likes
|
Last Post Today, 07:23 AM | ||
Started by cocoescala, 10-12-2018, 11:02 PM
|
7 responses
944 views
0 likes
|
Last Post
by Jquiroz1975
Today, 07:21 AM
|
Comment