![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
In various Drawing Object properties "startTime" and "endTime" are listed as optional arguments. What is the proper format for startTime if the time is 9:45 AM? I tried 94500 and it shut down my indicator completely.
Thanks |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,197
Thanks: 135
Thanked 181 times in 180 posts
|
Hello kenb2004,
The startTime and endTime are going to use a DateTime object not just an integer for a reference. For an example on how to use and modify DateTime objects you may view the following forum post for a sample. http://www.ninjatrader.com/support/f...ad.php?t=19292 Please let me know if I can be of further assistance.
JC
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
I'm sorry but that sample does not answer my question. What do I put in the startTime argument for Today at 9:30 AM? This is as simple a question as I can get.
Last edited by kenb2004; 07-16-2012 at 11:01 AM.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,197
Thanks: 135
Thanked 181 times in 180 posts
|
Hello kenb2004,
The SampleDateTimeFunctions shows the formats of the DateTime object use. So you could create a new DateTime object for the startTime and endTime of the object that you want to draw at those specific times. Another reference that you can use is the VWAP indicator that creates new DateTime series at the following link. http://www.ninjatrader.com/support/f...id=1&linkid=71 To read more information about DateTime you may view the following link. http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx Please let me know if I can be of further assistance.
JC
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
JC
What's the point? Why not an integer? If you used ToTime instead of DateTime wouldn't it be simpler. What is the purpose of the complication? Is one more accurate or what? Declaring, defining, properties, why not an integer? |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Ken,
There's always more than one way to do things and you're welcome to explore the best approach that works for you. The drawing object based on time requires a standard C# DateTime object, but each component (year, hour, minute, etc) could be built with an integer input if that's what you're looking to do. Code:
DateTime myDateTime = new DateTime(myYearInput, myMonthInput, myDayInput, myHourInput, myMinuteInput, mySecondinput);
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
So based on the sample code you supplied, what would you use for Today for myDayinput? Since chart data is calculated on a daily basis.
DateTime now = DateTime.Now???
Last edited by kenb2004; 07-16-2012 at 01:35 PM.
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,197
Thanks: 135
Thanked 181 times in 180 posts
|
Hello kenb2004,
DateTime.Now will get a DateTime object that is set to the current date and time on this computer, expressed as the local time. Meaning that if you run the indicator at 2:23:35 PM today, it will return "7/16/2012 2:23:35 PM". You can define a specific date and time when you create a new DateTime object for example: Code:
// Sets the myDateTime to July 16, 2012 at 8:49:00AM DateTime myDateTime = new DateTime(2012, 7, 16, 8, 49, 0 ); http://www.ninjatrader.com/support/h...tellisense.htm Here is a link to our support forums that goes over how to debug your code which comes in handy when writing custom code to see how your code is being processed and to see what values are being set. http://www.ninjatrader.com/support/f...ead.php?t=3418 Please let me know if I can be of further assistance.
JC
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
Thank you for all the information concerning DateTime and all it's functions. But I still don't understand how using NinjaScript you would DrawRegion from 10 to 11 AM. Usually I would go to the Wizard and see how it does it but it's not there. Or I would go to the User Guide and search startTime or endTime but it only refers to it, but with no explanation.
I realize that DrawRegion is fairly new, but I would like to use the time property but I just don't know how. Maybe you or Josh could do a quick Sample using DrawRegion with a start and endtime property that draws every day at the same time. I'm sure it would be appreciated by others on this forum as well. Thanks
Last edited by kenb2004; 07-16-2012 at 03:13 PM.
|
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,197
Thanks: 135
Thanked 181 times in 180 posts
|
Hello kenb2004,
This will require you to set a DateTime object for the startTime and endTime to be able to define a time frame in which to draw. For example: Code:
// Sets the myStartTime to July 16, 2012 at 10:00:00AM DateTime myStartTime = new DateTime(2012, 7, 16, 10, 0, 0 ); // Sets the myEndTime to July 16, 2012 at 11:00:00AM DateTime myEndTime = new DateTime(2012, 7, 16, 11, 0, 0 ); There is a reference sample using DrawRegion that you may view at the following link. http://www.ninjatrader.com/support/f...ead.php?t=4331 I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm The following link is a website that offers classes on programming in NinjaTrader that you may view for more programming experience and knowledge. http://www.ninjaprogrammingschool.com/ Alternatively, If you have limited time or programming experience, you can discuss your requirements with any of our certified NinjaScript consultants at the link below. http://www.ninjatrader.com/partners#...pt-Consultants Please let me know if I can be of further assistance.
JC
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
It's amazing, all I asked was a simple question as to the format NinjaTrader requires for startTime and endTime and I've been directed to the MSDN site, Ninja tutorials that don't cover this topic, 2 reference samples that do not create a startTime or endTime, a site to pay for programing education, and a site to hire a programmer. When all I asked was for a sample that would demonstrate the use of your own DateTime property in a drawing object. You have SampleIndicators for lot's of others why not one for startTime and endTime for DrawRegion daily from 10 to 11 AM.
Thanks |
|
|
|
|
|
#12 | |
|
Senior Member
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
|
Ummm
Code:
// Sets the myStartTime to July 16, 2012 at 10:00:00AM
DateTime myStartTime = new DateTime(2012, 7, 16, 10, 0, 0 );
// Sets the myEndTime to July 16, 2012 at 11:00:00AM
DateTime myEndTime = new DateTime(2012, 7, 16, 11, 0, 0 );
// Fills in the region between the upper and lower bollinger bands
DrawRegion("tag1", myStartTime, myEndTime, CurrentBar, 0,
Bollinger(2, 14).Upper, Bollinger(2, 14).Lower,
Color.Empty, Color.Lime, 2);
Quote:
|
|
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
Thanks sledge
// Sets the myStartTime to July 16, 2012 at 10:00:00AM DateTime myStartTime = new DateTime(2012, 7, 16, 10, 0, 0 ); I see this code covers the 10 to 11 part, but this appears to be setting the startTime date to yesterday, how will this work for Today? What about the "daily" part? Normally when you want to capture the value of a bar, you would put "+CurrentBar" in the tag argument. With this code how do you capture the value of the DrawRegion so that 10 to 11 DrawRegion is unique for each day. Would you put "tag1" + Time[0].Date.ToString(), in the tag argument? But if your startTime date is yesterday's date, how will it draw Today? Thanks
Last edited by kenb2004; 07-17-2012 at 05:02 AM.
|
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
Ken,
Instead of using this with hard set values. DateTime myStartTime = new DateTime(2012, 7, 16, 10, 0, 0 ); You would instead use: DateTime myStartTime = new DateTime(Time[0].Year.ToString() , Time[0].Month.ToString(), Time[0].Day.ToString(), 10, 0, 0 ); This is working with DateTime structures which is a core c# component. -Brett
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
Bret
This is perfect. Thank you very much. Just 2 other questions. 1. Why DateTime and not ToTime? 2. Would NinjaTrader consider an addition to Syntax for Drawing objects including ToTime startTime and endTime for those traders who only need hhmmss without the bulk of DateTime coding? Thanks again |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Transfering data from Multicharts data format to Ninja Trader data format | alex_inditraders | General Programming | 7 | 03-01-2012 03:20 AM |
| Problems with ticks happening at session EndTime | gomifromparis | Version 7 Beta General Questions & Bug Reports | 12 | 11-16-2010 10:03 AM |
| BeginTime EndTime timezone ? | gomifromparis | Version 7 Beta General Questions & Bug Reports | 21 | 02-12-2010 09:11 AM |
| Converting eSignal OnDemand output file format to NT historical data input format | AnotherTrader | Connecting | 0 | 09-15-2009 07:21 AM |
| Time Format | grd974 | General Programming | 6 | 08-13-2007 06:45 AM |