Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ToDay & ToTime

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

    ToDay & ToTime

    I am recording a log and I need to register the date and the hour of event.

    I am using " string Key = ToDay(Time[0]).ToString() + ";" + ToTime(Time[0]).ToString() + ";" ..."

    What is recorded is a date of two days ago and a time that I do not know where it comes from.

    What should I do?

    #2
    Originally posted by sasil View Post
    What should I do?
    Try something like this,
    Code:
    Time[0].ToString("M/d/yy HH:MM:ss");
    See here for more examples:
    Learn to use custom date and time format strings to convert DateTime or DateTimeOffset values into text representations, or to parse strings for dates & times.
    Last edited by bltdavid; 06-15-2016, 05:15 PM.

    Comment


      #3
      Originally posted by sasil View Post
      I am recording a log and I need to register the date and the hour of event.

      I am using " string Key = ToDay(Time[0]).ToString() + ";" + ToTime(Time[0]).ToString() + ";" ..."

      What is recorded is a date of two days ago and a time that I do not know where it comes from.

      What should I do?
      Take off the ToString?

      Code:
      " string Key = ToDay(Time[0]) + ";" + ToTime(Time[0]) + ";" ..."

      Comment


        #4
        Hello sasil,

        Thanks for your post.

        If you haven't already gotten an answer regarding the use of time, using Time[0] will provide the end time of the current bar and if you are using long time frame bars the log may not accurately reflect the event time.

        If you are needing real time, you can use Print ("Date-Time: "+DateTime.Now); example: Date-Time: 6/16/2016 6:23:27 AM

        Member bltdavid provided a link for reference, here is another link of examples: http://www.dotnetperls.com/datetime

        Comment


          #5
          Thanks for your replies.
          I think I found the problem of the date and time wrong. I was running my routine into the OnStartup (). Now I put in the OnBarUpdate () and the date and time are correct.
          Now I will try to hit the formats.
          Thanks...

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          583 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          338 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X