• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to get seconds/minutes passed after bar start?

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

    how to get seconds/minutes passed after bar start?

    I thought Time[0] would give me i.e. 09:47:31 (hour,minute,second) on the last, realtime bar.


    when on realtime chart (lets say, 5 min), i thought:

    Time[0]-Time[1] would give i.e. 2 mins, if 2 minutes is passed after bar start. however it doesnt do that.


    how to get current minutes passed after the last bar started?
    Probably with datetimes, but a i say, i cant make it work.

    #2
    Found one solution for only LIVE-BAR - DateTime.Now.

    however, that doesnt work in backtesting.. for example, when TickReplay is, i cant still get current H:M:S of execution on that tick. Time[0] always returns such time:

    09:35:00
    09:40:00
    ....etc

    Comment


      #3
      Hello,

      Thanks for your post.

      Instead of Time[0]-Time[1] To get the time since the last bar started in OnBarUpdate() you would compare the times you mentioned similar to the snippet below:

      Time[0].Subtract(Time[1])

      The following help guide article will go into further detail on the DateTime object.

      https://msdn.microsoft.com/en-us/lib....datetime.aspx

      If you have any further questions please let me know.
      JoshNinjaTrader Customer Service

      Comment


        #4
        Time[0].Subtract(Time[1]) even returns the same value as `Time[0]-Time[1]`.

        The only solution seems (but not in simple backtesting) DateTime.Now - Time[1], but this works only in LIVE data (or Market Replay).

        Also, i am trying to solve the problem with granularity/ intrabar orders, but in backtesting, i have some problems at this moment.
        However, thanks for help!

        Comment


          #5
          Originally posted by selnomeria View Post
          Time[0].Subtract(Time[1]) even returns the same value as `Time[0]-Time[1]`.

          The only solution seems (but not in simple backtesting) DateTime.Now - Time[1], but this works only in LIVE data (or Market Replay).

          Also, i am trying to solve the problem with granularity/ intrabar orders, but in backtesting, i have some problems at this moment.
          However, thanks for help!
          The only way to get intrabar granularity access in NT7 is to use a secondary price series. I always use 1-second, but there are those that insist that one must use 1-tick.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by U0000999, Today, 05:17 AM
          0 responses
          3 views
          0 likes
          Last Post U0000999  
          Started by Prataturry89, Today, 03:40 AM
          0 responses
          5 views
          0 likes
          Last Post Prataturry89  
          Started by UltraFastKetoBoost28, Today, 02:43 AM
          0 responses
          6 views
          0 likes
          Last Post UltraFastKetoBoost28  
          Started by kojakojids, Today, 02:04 AM
          0 responses
          5 views
          0 likes
          Last Post kojakojids  
          Started by pitifak, Today, 01:01 AM
          0 responses
          4 views
          0 likes
          Last Post pitifak
          by pitifak
           
          Working...
          X