GetTimeBySlotIndex()

View as Markdown

Definition

Returns a time value relative to the chart control corresponding to a specified slot index.

Notes:

  • A “Slot” is used in Equidistant bar spacing and represents a position on the chart canvas background which may or may not contain a bar. The concept of “Slots” does NOT exist on a TimeBased bar spacing type.
  • If you are looking for information on a bar series, please see ChartBars.GetTimeByBarIdx().
  • For slot index values in the future, an estimation of time will be returned. It is not possible to predict the future time of a bar for all bar series (i.e., tick/volume based bars).

Method Return Value

A DateTime object corresponding to a specified slot index; returns DateTime value for ‘now’ on a time based bar spacing type.

Syntax

\<chartcontrol\>.GetTimeBySlotIndex(double slotIndex)

Method Parameters

ParameterDescription
slotIndexThe slot index used to determine a time value

Examples

1protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
2{
3 // Find the timestamp of the bar at index 150
4 DateTime slotTime = chartControl.GetTimeBySlotIndex(150);
5
6 // Print the date of slotTime
7 Print(slotTime.Date);
8}