Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,229 views
            0 likes
            Last Post xiinteractive  
            Started by andrewtrades, Today, 04:57 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            7 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            441 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            12 views
            0 likes
            Last Post FAQtrader  
            Working...
            X