Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.GetTime not equivalent to Time[]

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

    Bars.GetTime not equivalent to Time[]

    Hi,
    when accessing daily bars, which when accessing the time with the Time series such as Time[n], the bar stamp is the end of the main session, e.g. 5PM New York for the ES.
    However, when using Bars.GetTime(idx), it only returnsthe date, and the timestamp is midnight.

    I had the daily bars loaded as a 2nd DataSeries inside an indicator.

    **
    In addition, within OnRender(), the Time DataSeries is screwy. Times[1][0] reports the first bar time, despite the CurrentBars[1] being a high number, e.g. 200.


    **
    Also, the Times are reporting incorrectly.
    Time[1] is larger than Time[0]. This is in OnBarUpdate() on a 2nd DataSeries of day bars.

    index 0 is 8/09/2016 5:00:00 PM matches bar 1187 8/09/2016 5:00:00 PM
    index 1 is 9/09/2016 5:00:00 PM matches bar 1192 8/09/2016 8:30:00 PM
    index 2 is 7/09/2016 5:00:00 PM matches bar 1141 7/09/2016 5:00:00 PM
    index 3 is 6/09/2016 5:00:00 PM matches bar 1095 6/09/2016 5:00:00 PM

    Here is the code that produced that result. pivotTimes and pivotIndexes are List objects.

    Code:
    pivotTimes.Clear();
    					pivotIndexes.Clear();
    					for (int x = 0; x<=CurrentBar; x++)
    					{
    						pivotTimes.Add(Time[x]);
    						pivotIndexes.Add(BarsArray[0].GetBar(Time[x]));	
    						if (pivotIndexes[pivotIndexes.Count-1] > 0)
    							Print("index "+x+" is "+Time[x]+" matches bar "+pivotIndexes[pivotIndexes.Count-1]+" "+Times[0][CurrentBars[0]-pivotIndexes[pivotIndexes.Count-1]]);
    					}
    saltminer
    Last edited by saltminer; 09-08-2016, 06:20 PM. Reason: new information

    #2
    Hello,

    Thank you for the post.


    I will test your first item to see if I can also see this result.


    Regarding OnRender, this is expected because this is outside of the scope of the Event driven methods such as OnBarUpdate.

    To get values from OnRender, Button events, or other locations that are not directly related to OnBarUpdate, you would need to use the Get methods. This was changed as of B11, noted in the Implementation changes section:




    For the remaining question

    I tried the syntax provided but I am getting a index error when I run the code after adding in the variables.

    Could you provide a complete sample along with the output that was produced from that sample?

    I see that the loop had run for some bars before the index error, but I did not get the same output likely because the scripts are not identical.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by saltminer View Post
      Hi,
      when accessing daily bars, which when accessing the time with the Time series such as Time[n], the bar stamp is the end of the main session, e.g. 5PM New York for the ES.
      However, when using Bars.GetTime(idx), it only returnsthe date, and the timestamp is midnight.
      I looked into this with development and they let me know that the Bars.GetTime() method will display whatever is formatted in the chart's data box.

      If you need the daily bar to include the session end time, as TimeSeries[n] returns, you can use Bars.GetSessionEndTime()



      I also added a note on the Bars.GetTime() help guide page to make note of this behavior:

      MatthewNinjaTrader Product Management

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by The_Sec, Today, 02:29 PM
      0 responses
      1 view
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by tsantospinto, 04-12-2024, 07:04 PM
      4 responses
      62 views
      0 likes
      Last Post aligator  
      Started by michi08, 10-05-2018, 09:31 AM
      3 responses
      741 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by sightcareclickhere, Today, 01:55 PM
      0 responses
      1 view
      0 likes
      Last Post sightcareclickhere  
      Started by Mindset, 05-06-2023, 09:03 PM
      9 responses
      259 views
      0 likes
      Last Post ender_wiggum  
      Working...
      X