Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to find the bars Opening time?

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

    How to find the bars Opening time?

    Time[0] gives the closing time of the bar. How to find out the time when this bar appeared on the chart (time of its opening)?

    By analogy with the MQL: iTime (_Symbol, _Period, 0) gives the opening time of the current bar. Is there anything similar in the NS?

    #2
    Hello webus,

    Thanks for your post and welcome to the NinjaTrader Forums!

    Ninjatrader does timestamp the end of the bar, other platforms timestamp the beginning of the bar.

    The beginning of the bar would be relatively the same time as the end of the previous bar. So the start time of the current bar would be equal to Time[0] - (Time[0] - Time[1]). Here is a print statement you could use to see this: Print ("Bar Start time: "+(Time[0] -(Time[0] - Time[1])).ToString()+ " Bar End time: "+Time[0]);

    A more precise way, on real time data, would be to add a 1 tick series and use Bars.IsFirstTickOfBar on the primary series and collect the time from the tick series bar.
    Reference: https://ninjatrader.com/support/help...ttickofbar.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello webus,

      The beginning of the bar would be relatively the same time as the end of the previous bar. So the start time of the current bar would be equal to Time[0] - (Time[0] - Time[1]). Here is a print statement you could use to see this: Print ("Bar Start time: "+(Time[0] -(Time[0] - Time[1])).ToString()+ " Bar End time: "+Time[0]);
      Hi PaulH.
      I think I can not agree with you.
      For example, chart Minute 1. The trading week closed on Friday at 23:59 (closing time of the last bar). A new week began on Monday at 00:00 (00:01 the closing time of the first bar).
      According to your formula, the opening time of the first bar on Monday is Friday 23:59. This is not true and not what I need.
      I want to get 00:00 Monday in this case.


      Comment


        #4
        Hello webus,

        Thanks for your reply.

        If you are using time based bars (I was assuming you were not using time based bars), then (in the case of 1 minute bars) you can subtract 1 minute from the bars time stamp. Print ("Start time of bar: "+Time[0].AddMinutes(-1)+" End of Bar: "+Time[0]);
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_PaulH View Post
          Hello webus,

          Thanks for your reply.

          If you are using time based bars (I was assuming you were not using time based bars), then (in the case of 1 minute bars) you can subtract 1 minute from the bars time stamp. Print ("Start time of bar: "+Time[0].AddMinutes(-1)+" End of Bar: "+Time[0]);
          Hi PaulH.

          Thanks for the answer. At the moment I am using the same method. I thought that there is some more universal method (something like a dataseries).

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by llanqui, Today, 03:53 AM
          0 responses
          6 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          10 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          15 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          14 views
          0 likes
          Last Post strategist007  
          Working...
          X