ChartControl

View as Markdown

The ChartControl class provides access to a wide range of properties and methods related to the location of objects on a chart and other chart-related properties. The ChartControl object provides information related to the entire hosting grid of the chart, which overlap with the ChartPanel, ChartScale and ChartBars.

The ChartControl object is ONLY guaranteed to be available when a NinjaScript type initiates from a Chart Window. There are situations where an indicator or strategy starts from another Windows (such as the Control Center’s Strategies Grid, or from a Strategy Analyzer), where the ChartControl object is NOT accessible. Therefore, the ChartControl object should always be safely accessed (e.g., from within a try-catch, or conditionally using null reference checks).

ChartControl_1

Warning: The ChartControl and its methods and properties should ONLY be accessed once the State has reached State.Historical.

Methods and Properties

Method/PropertyDescription
AxisXHeightMeasures the distance (in pixels) between the x-axis and the top of the horizontal scroll bar
AxisYLeftWidthMeasures the distance (in pixels) between the y-axis and the left margin of a chart
AxisYRightWidthMeasures the distance (in pixels) between the y-axis and the right margin of a chart
BarMarginLeftMeasures the margin to the left of each bar on the chart, in pixels
BarsArrayProvides a collection of ChartBars objects currently configured on the chart
BarSpacingTypeProvides the type of bar spacing used for the primary Bars object on the chart
BarsPeriodProvides the period (interval) used for the primary Bars object on the chart
BarWidthMeasures the value of the bar width set for the primary Bars object on the chart
BarWidthArrayAn array containing the values of the BarWidth properties of all Bars objects on the chart
CanvasLeftIndicates the x-coordinate (in pixels) of the beginning of the chart canvas area
CanvasRightIndicates the x-coordinate (in pixels) of the end of the chart canvas area
CanvasZoomStateIndicates the current state of the Zoom tool on the chart
ChartPanelsHolds a collection of ChartPanel objects
CrosshairTypeIndicates the Cross Hair type currently enabled on the chart
FirstTimePaintedIndicates a time value of the first bar painted on the chart
GetBarPaintWidth()Returns the width of the bars in the primary Bars object on the chart, in pixels
GetSlotIndexByTime()Returns the slot index of the primary Bars object on the chart corresponding to a specified time value
GetSlotIndexByX()Returns the slot index of the primary Bars object on the chart corresponding to a specified x-coordinate on the visible chart canvas
GetTimeBySlotIndex()Returns a time value corresponding to a specified slot index of the primary Bars object on the chart
GetTimeByX()Returns a time value related to the primary Bars’ slot index at a specified x-coordinate on the chart canvas
GetXByBarIndex()Returns the chart-canvas x-coordinate of the bar at a specified index of a specified ChartBars object on the chart
GetXByTime()Returns the chart-canvas x-coordinate of the slot index of the primary Bars object corresponding to a specified time
IndicatorsReturns a collection of indicators currently configured on the chart
IsScrollArrowVisibleIndicates the time-axis scroll arrow is visible in the top-right corner of the chart
IsStayInDrawModeIndicates the Stay in Draw Mode is currently enabled on the chart
IsYAxisDisplayedLeftIndicates the y-axis displays (in any chart panel) to the left side of the chart canvas
IsYAxisDisplayedOverlayIndicates an object on the chart is using the Overlay scale justification
IsYAxisDisplayedRightIndicates the y-axis displays (in any chart panel) to the right side of the chart canvas
LastSlotPaintedIndicates the slot index of the most recently painted bar on the primary Bars object configured on the chart
LastTimePaintedIndicates the time of the most recently painted bar on the primary Bars object configured on the chart
MouseDownPointIndicates the x- and y-coordinates of the mouse cursor at the most recent OnMouseDown() event
PropertiesA collection of properties related to the configuration of the Chart
SlotsPaintedIndicates the number of index slots in which bars are painted within the chart canvas area
StrategiesA collection of strategies configured on the chart
TimePaintedIndicates the range of time in which bars are painted on the visible chart canvas