Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Different Times Using Time[0] and BarsArray[0].GetTime()

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

    Different Times Using Time[0] and BarsArray[0].GetTime()

    I have noticed that when I'm using a daily data series that the time value is different between these two ways of getting the time:

    1) Time[0] gives the time as 4:00pm (I'm set to central time)
    2) BarsArray[0].GetTime(CurrentBar) gives the time as 12:00am

    I've had various places I need to do some comparisons and I keep bumping up against this difference.

    I'd really like to know what's behind this. Is it a bug, a feature or something I'm doing wrong?

    I did the follow test with ES ##-## Kinetick data.


    Time[0] = 11/16/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/16/2018 12:00:00 AM
    Time[0] = 11/19/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/19/2018 12:00:00 AM
    Time[0] = 11/20/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/20/2018 12:00:00 AM
    Time[0] = 11/21/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/21/2018 12:00:00 AM
    Time[0] = 11/23/2018 12:15:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/23/2018 12:00:00 AM
    Time[0] = 11/26/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/26/2018 12:00:00 AM
    Time[0] = 11/27/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/27/2018 12:00:00 AM
    Time[0] = 11/28/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/28/2018 12:00:00 AM
    Time[0] = 11/29/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/29/2018 12:00:00 AM
    Time[0] = 11/30/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 11/30/2018 12:00:00 AM
    Time[0] = 12/3/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 12/3/2018 12:00:00 AM
    Time[0] = 12/4/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 12/4/2018 12:00:00 AM
    Time[0] = 12/5/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 12/5/2018 12:00:00 AM
    Time[0] = 12/6/2018 4:00:00 PM, BarsArray[0].GetTime(CurrentBar) = 12/6/2018 12:00:00 AM

    Code:
    using System;
    
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators.Barz.Sandbox
    {
        public class BarzTestTimeValues : Indicator
        {
    
            protected override void OnBarUpdate()
            {
                if (CurrentBar <= BarsRequiredToPlot) { return; }
    
                DateTime dt0 = Time[0];
                DateTime dtCurrent = BarsArray[0].GetTime(CurrentBar);
                Print("Time[0] = " + dt0.ToString() + ", BarsArray[0].GetTime(CurrentBar) = " + dtCurrent.ToString());
    
            }
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Calculate = Calculate.OnBarClose;
                    Name = "Barz - Test Time Values";
                }
            }
        }
    }

    #2
    Hello BarzTrading,

    From the help guide on Bars.GetTime():
    "Note: This method will return what is displayed in the chart's data box. For formatting purposes, the value returned is NOT guaranteed be equal to the TimeSeries value. If you are using daily bars and need the session end time, you should use Bars.GetSessionEndTime() instead."

    Below is a public link to the help guide on Bars.GetTime().


    And a public link on Bars.GetSessionEndTime().
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      OK. Thank you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      44 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      54 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      34 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      94 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      56 views
      0 likes
      Last Post PaulMohn  
      Working...
      X