Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StartTime/EndTime format?

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

    StartTime/EndTime format?

    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
    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.
    JCNinjaTrader Customer Service

    Comment


      #3
      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, 11:01 AM.

      Comment


        #4
        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.
        JCNinjaTrader Customer Service

        Comment


          #5
          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?

          Comment


            #6
            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

            Comment


              #7
              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.

              Comment


                #8
                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
                JCNinjaTrader Customer Service

                Comment


                  #9
                  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.

                  Comment


                    #10
                    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.
                    JCNinjaTrader Customer Service

                    Comment


                      #11
                      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

                      Comment


                        #12
                        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

                        Comment


                          #13
                          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.

                          Comment


                            #14
                            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

                            Comment


                              #15
                              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

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by fx.practic, 10-15-2013, 12:53 AM
                              5 responses
                              5,404 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by Shai Samuel, 07-02-2022, 02:46 PM
                              4 responses
                              95 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by DJ888, Yesterday, 10:57 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by MacDad, 02-25-2024, 11:48 PM
                              7 responses
                              159 views
                              0 likes
                              Last Post loganjarosz123  
                              Started by Belfortbucks, Yesterday, 09:29 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post Belfortbucks  
                              Working...
                              X