GetTimeByX()

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Common > Charts > ChartControl >

GetTimeByX()

Previous page Return to chapter overview Next page

Definition

Returns a time value related to the primary Bars' slot index at a specified x-coordinate relative to the ChartControl.

 

Note:  Since the time is based upon a coordinate of the chart canvas, the value returned by GetTimeByX() can be expected to change as new bars are painted on the chart, or as the chart is scrolled backward or forward on the x-axis.

 

 

Method Return Value

A DateTime object corresponding to a slot index at a specified x-coordinate

 

Syntax
<ChartControl>.GetTimeByX(int x)

 

 

Method Parameters

x

The x-coordinate used to find a time value

 

 

Example

ns

protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
  // Find the timestamp of the bar at x-coordinate 100
  DateTime slotTime = chartControl.GetTimeByX(100);
 
  // Print the date of slotTime
  Print(slotTime);
}