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 judysamnt7, 03-13-2023, 09:11 AM
          4 responses
          53 views
          0 likes
          Last Post DynamicTest  
          Started by ScottWalsh, Today, 06:52 PM
          4 responses
          33 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Today, 07:39 PM
          0 responses
          5 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          19 views
          0 likes
          Last Post helpwanted  
          Started by cre8able, Today, 07:24 PM
          0 responses
          6 views
          0 likes
          Last Post cre8able  
          Working...
          X