Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Timer for Constant Range Bars

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

    Timer for Constant Range Bars

    Hi

    I would like to develop a timer that counts the seconds between the open and the close of a constant range bar but I am having difficulties to find the appropriate syntax that calls the "seconds" variable.

    Thanks for pointing me in the right direction.

    #2
    Time[0] returns a DateTime structure - http://msdn2.microsoft.com/en-us/lib....datetime.aspx

    You can then subtract the current Time[0] from the prior Time[1] which gives you a TimeSpan object - http://msdn2.microsoft.com/en-us/lib....timespan.aspx

    A TimeSpan object has a "TotalSeconds" property on it.
    RayNinjaTrader Customer Service

    Comment


      #3
      Hello Ray

      Thanks for your reply but I'm still having trouble with the following:
      The time format is the following:

      For example: open of the bar at 13.15 and 57 sec
      close of the bar 13.16 and 07 sec

      Total time of the bar is: 10 seconds. The problem is that the formula calculates the time like this: 131607-131557. The result obviously isn't correct.

      What can I do to correct that?

      Thanks a lot.

      Comment


        #4
        Not sure I follow.

        If you are working with the DateTime class in .NET and subtracting one time from another, you get back a TimeSpan object. The TimeSpan object has a TotalSeconds property on it that would return 10 seconds in your example.
        RayNinjaTrader Customer Service

        Comment


          #5
          Thanks for that, I managed to get the raw time with Total Seconds indeed.
          I'm still having trouble though linking the Current Time to the bar close and the Prior Time to the bar open, thus getting the total duration of the bar in seconds.

          Thanks a lot.

          Comment


            #6
            Unfortunatley I do not understand what you mean by linking current time to bar close etc...
            RayNinjaTrader Customer Service

            Comment


              #7
              The previous bar's close is generally the current bar's open time. This is why you can use Time[1] - Time[0]. The result is the time on the current bar, from open to close.
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

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