• 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

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().
    https://ninjatrader.com/support/help...us/gettime.htm

    And a public link on Bars.GetSessionEndTime().
    https://ninjatrader.com/support/help...ionendtime.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      OK. Thank you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ralett, Today, 11:44 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Spencer  
      Started by DMDINAZ, Today, 11:03 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by sukhob, Today, 10:14 AM
      4 responses
      10 views
      0 likes
      Last Post sukhob
      by sukhob
       
      Started by beaacontreras, Today, 09:27 AM
      1 response
      21 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by fxSol, 03-17-2019, 04:17 AM
      5 responses
      28 views
      0 likes
      Last Post NinjaTrader_ChristopherS  
      Working...
      X