Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 AnnBarnes, Today, 12:17 PM
      0 responses
      2 views
      0 likes
      Last Post AnnBarnes  
      Started by Lopat, 03-05-2023, 01:19 PM
      4 responses
      167 views
      0 likes
      Last Post Sam2515
      by Sam2515
       
      Started by f.saeidi, Today, 12:14 PM
      0 responses
      3 views
      0 likes
      Last Post f.saeidi  
      Started by giulyko00, Today, 12:03 PM
      0 responses
      4 views
      0 likes
      Last Post giulyko00  
      Started by AttiM, 02-14-2024, 05:20 PM
      12 responses
      213 views
      0 likes
      Last Post DrakeiJosh  
      Working...
      X