GetTime()

View as Markdown

Definition

Returns the time stamp at the current bar index value.

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

Method Return Value

A DateTime structure that represents the time stamp at the desired bar index.

Syntax

Bars.GetTime(int index)

Parameters

ParameterDescription
indexAn int representing an absolute bar index value

Examples

1protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
2{
3 base.OnRender(chartControl, chartScale);
4 // loop through only the rendered bars on the chart
5 for(int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
6 {
7 // get the time stamp at the selected bar index value
8 DateTime timeValue = Bars.GetTime(barIndex);
9 Print("Bar #" + barIndex + " time stamp is " + timeValue);
10 }
11}