Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get TRUE UTC time for every execution?

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

    How to get TRUE UTC time for every execution?

    Hi,

    I'm not able to understand how the timezone system works on NT8.

    Here's an example:
    System/OS time: Amsterdam
    NT time: US/Canada (ET) (Exchange time)
    Trade executed on: 10:07:26 (24-hr)


    `e.Execution.Time.ToString("yyyy-MM-dd HH:mm:ss")`
    Returns: 2023-02-13 10:07:26

    `e.Execution.Time.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss")`​
    Returns: 2023-02-13 09:07:26



    How is the UTC time correct? The correct UTC time is 15:07:26.


    Now, my question is: How can I get the *correct* UTC time irrespective of NT zone or user's computer/OS zone?

    Thank you

    #2
    Hello tmmr34,

    The execution's would be reported based on the timestamp the broker provided for the execution time. If you need a UTC time you need to convert the time to UTC time. You can likely use DateTime.ToUniversalTime() for this use case. https://learn.microsoft.com/en-us/do...tframework-4.8



    Comment


      #3
      Hi,

      >The execution's would be reported based on the timestamp the broker provided for the execution time.

      So this is irrespective of local timezone or NT timezone? What about the case when the user is using the simulation mode but with live data?


      >You can likely use DateTime.ToUniversalTime() for this use case

      That is exactly what I'm using if you see my post... and I still don't see the correct UTC time as the trade I mentioned in my post was made during market hrs at around 10am ET.


      Comment


        #4
        Hello tmmr34,

        For a live execution the executions time is reported as part of the execution's event, to know a UTC time you would need to convert that time. For a sim execution that would be based on your local settings and the platforms time settings.

        You may want to try using ConvertTimeToUtc which is another method in C# on the DateTime class. I would otherwise not have a suggestion here, converting DateTimes would be outside of the scope of NinjaScript. DateTime is part of the C# language so you may need to use external tutorials on converting DateTimes to achieve the exact result you wanted.

        Learn to convert times between from one time zone to another in .NET. Also learn to convert DateTimeOffset values that have limited time zone awareness.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        566 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X