Thx.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Date time as input variables
Collapse
X
-
"Date" is a DateTime variable.Originally posted by Hawk Arps View PostIf I want to use a date and a time as an input variable, under what 'class' do I declare them, and in what format do I input them?
Thx.
If by "time", you mean a time of day, sans the date, that will be a TimeSpan variable.Last edited by koganam; 01-08-2012, 06:41 PM.
Comment
-
No. StartTime, as you have declared it, should be a TimeSpan variable.Originally posted by Hawk Arps View PostDoes this mean that if I want to declare a date and a time input variable and default them to 6:30 AM Sept. 1, 2011 I would use the following code?
(within Variables)
new DateTime StartDate=2011,09,01;
new DateTime StartTime=06:30:00;
It should be properly declared as:
Of course, you can always make a blank declaration, then assign it later.Code:TimeSpan StartTime = new TimeSpan(6, 30, 00);
Last edited by koganam; 01-10-2012, 01:33 AM.
Comment
-
Thank you for your help... But I'm still pretty confused on how to declare a date (ie: Sept,1,2011) as an input and how to compare the current bar date to that date in the code. Everything I'm trying is getting compiler error code CS0120. Obviously I'm still pretty low on the learning curve...
Comment
-
I see... this indicator only works in real time. If I want to mark past times I assume I would change the DateTime.Now in the code DateTime(DateTime.Now.Year,DateTime.Now.Month,Date Time.Now.Day..... to Time[0].Date
Again thanks for the help. I'm slowly getting it (I think).
Comment
-
Hello NT,
I'm resurrecting this really old thread because it is somewhat close to what I'm trying to do. Hawk Arps was trying to mark out past dates. Bertrand gave him an indicator called DatetimeVerticalLines.cs. Hawk Arps was able to catch on how to mark past dates, but I'm still lost. Here is where the thread left off:
I would appreciate if anyone can show me how to put the vertical line on a past date, for example, July 19, 2017.I see... this indicator only works in real time. If I want to mark past times I assume I would change the DateTime.Now in the code DateTime(DateTime.Now.Year,DateTime.Now.Month,Date Time.Now.Day..... to Time[0].Date
Again thanks for the help. I'm slowly getting it (I think).
Thanks
Gennaker
Comment
-
Hello Gennaker,
Thank you for the follow up.
You may use this constructor to specify a date to draw a line:
DrawVerticalLine(string tag, DateTime time, Color color, DashStyle dashStyle, int width)[/CODE]
Exemplar:
This will Draw a vertical line on July 19th 2017 at 12PM.Code:DrawVerticalLine("My Line", new DateTime(2017, 7, 19, 12, 0, 0), Color.Red, DashStyle.Solid, 2);
More on DrawVerticalLine() here:
Please let us know if we may be of any further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 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