IsFirstBarOfSessionByIndex()

View as Markdown

Definition

Indicates if the selected bar index value is the first bar of a trading session.

Property Value

This property returns true if the bar is the first bar of a session; otherwise, false. This property is read-only.

Syntax

Bars.IsFirstBarOfSessionByIndex(int index)

Warning

This property will always return false on non-intraday bar periods (e.g., Day, Month, etc).

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 // check if the rendered bar is the first bar of the trading session
8 if (Bars.IsFirstBarOfSessionByIndex(barIndex))
9 {
10 DateTime slotTimeAtBarIndex = chartControl.GetTimeBySlotIndex(barIndex);
11 Print(string.Format("Bar index {0} was the first bar of the session at slot time {1}.", barIndex, slotTimeAtBarIndex));
12 }
13 }
14}