Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculate with milliseconds

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

    Calculate with milliseconds

    Why does Time[index].Millisecond always return 0 instead of milliseconds? Same with DateTime.Now.Millisecond.

    Or, if
    TimeSpan ts1 = Time[0] - Time[1]

    then ts1.TotalMilliseconds returns three zeros as the last three digits.
    I tried declaring ts1.TotalMilliseconds as long, but that didn't do the trick.

    Can someone help?

    #2
    Originally posted by Loki45 View Post
    Why does Time[index].Millisecond always return 0 instead of milliseconds? Same with DateTime.Now.Millisecond.

    Or, if
    TimeSpan ts1 = Time[0] - Time[1]

    then ts1.TotalMilliseconds returns three zeros as the last three digits.
    I tried declaring ts1.TotalMilliseconds as long, but that didn't do the trick.

    Can someone help?
    Time[index] is upto seconds only. NT hasnt implemented ms as of now. NT8 may be.

    Comment


      #3
      Originally posted by bukkan View Post
      Time[index] is upto seconds only. NT hasnt implemented ms as of now. NT8 may be.
      I suspected something like that, but what about the native .NET objects and constructs based on DateTime and TimeSpan? Don't they also work in the NinjaScript context like they would normaly do, down to a tick size of 100ns? This is the resolution the System.Namespace provides under the 3.5 framework.

      Comment


        #4
        Loki, would be believe lower granunlarity is possible in realtime with DateTime and TimeSpans in C#.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Loki, would be believe lower granunlarity is possible in realtime with DateTime and TimeSpans in C#.
          Well, you have TimeSpan.TotalMilliseconds, TimeSpan.Millisecond, Datetime.Now.Millisecond. So, that obviously is designed to work in real time.

          The property System.Environment.TickCount for example counts milliseconds from the last time the computer was turned on:

          "A 32-bit signed integer containing the amount of time in milliseconds that has passed since the last time the computer was started." [MSDN Help on .NET]

          All of the above does not seem to work within NinjaScript, not with a millisecond resolution.
          Last edited by Loki45; 02-12-2010, 07:52 AM.

          Comment


            #6
            Not sure in which context you work with those, but timestamps generally go down to second only.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 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
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X