Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StartTime/EndTime format?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • kenb2004
    replied
    koganam

    As always thanks for your expertise.

    Leave a comment:


  • koganam
    replied
    Originally posted by kenb2004 View Post
    No need to use a sledge hammer when a finishing hammer is the proper tool for the job. Graduating to DateTime would be a good thing when necessary, but it seems to me that all you did was make the Year, Month, and Date basically useless in this context, with only the hhmmss remaining. So then why use it in THIS application. NinjaTrader has obviouly designed Drawing Object syntax to be flexible for different programming needs. The DateTime "one size fits all" approach seems to be at odds with NinjaTrader's own flexibility standard.

    Thanks again for all your input
    Actually for what you want to do, you are going to have to access the DataTime() structure at some point as it is the only way you are going to get the value to differentiate different days: ToTime() is limited to returning an int, derived from the time component only.

    The point is then moot. If you are going to have to use the more powerful construct anyway, then just use it for everything in this particular instance.

    Leave a comment:


  • NinjaTrader_Brett
    replied
    No problem.

    Leave a comment:


  • kenb2004
    replied
    No need to use a sledge hammer when a finishing hammer is the proper tool for the job. Graduating to DateTime would be a good thing when necessary, but it seems to me that all you did was make the Year, Month, and Date basically useless in this context, with only the hhmmss remaining. So then why use it in THIS application. NinjaTrader has obviouly designed Drawing Object syntax to be flexible for different programming needs. The DateTime "one size fits all" approach seems to be at odds with NinjaTrader's own flexibility standard.

    Thanks again for all your input
    Last edited by kenb2004; 07-17-2012, 08:24 AM.

    Leave a comment:


  • NinjaTrader_Brett
    replied
    Hello,

    You want to use the right tool for the right job. In this case DateTime is the best format for the job. ToTime has limitations that make it not able to use here and is a basic format in general that I suggest you graduate into using DateTime if possible as they have features(Like the one I just showed you) that make it the superior format for Date and Time manipulation.


    -Brett

    Leave a comment:


  • kenb2004
    replied
    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

    Leave a comment:


  • NinjaTrader_Brett
    replied
    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

    Leave a comment:


  • kenb2004
    replied
    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, 05:02 AM.

    Leave a comment:


  • sledge
    replied
    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);
    Originally posted by kenb2004 View Post
    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

    Leave a comment:


  • kenb2004
    replied
    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

    Leave a comment:


  • NinjaTrader_JC
    replied
    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 );
    Then use myStartTime, and myEndTime in place of startTime and endTime respectively.

    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.

    Leave a comment:


  • kenb2004
    replied
    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, 03:13 PM.

    Leave a comment:


  • NinjaTrader_JC
    replied
    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 );
    Please note when using NinjaScript you can also use the built in intellisense to for more documentation. To read more information about intellisense you may view the following link. Also I have attached a screenshot of the DateTime intellisense.

    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.
    Attached Files

    Leave a comment:


  • kenb2004
    replied
    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, 01:35 PM.

    Leave a comment:


  • NinjaTrader_RyanM1
    replied
    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);

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by MikeTR, Today, 03:55 PM
0 responses
2 views
0 likes
Last Post MikeTR
by MikeTR
 
Started by sclay115, Today, 02:14 PM
0 responses
4 views
0 likes
Last Post sclay115  
Started by helmutmedina, Today, 01:57 PM
0 responses
6 views
0 likes
Last Post helmutmedina  
Started by renosdim01, 02-13-2025, 05:46 AM
2 responses
18 views
0 likes
Last Post renosdim01  
Started by zagier, 01-15-2025, 05:10 AM
13 responses
70 views
1 like
Last Post zagier
by zagier
 
Working...
X