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 cmtjoancolmenero, Yesterday, 03:58 PM
      3 responses
      23 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by Brevo, Today, 01:45 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by rjbtrade1, 11-30-2023, 04:38 PM
      2 responses
      72 views
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Started by suroot, 04-10-2017, 02:18 AM
      5 responses
      3,021 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by Stanfillirenfro, Today, 07:23 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X