Charts |
S# provides convenient components for charts plotting. These components are assembled in the StockSharp.Xaml.Charting namespace.
The key concept in the graphical library is a chart. Chart - is a container for other elements, which are used in the chart plotting. There are several types of charts in S#.
Chart - the graphical component for displaying the exchange charts.
ChartPanel - the advanced graphical component for displaying the exchange charts.
EquityCurveChart - the graphical component for displaying the equity curve.
BoxChart - the chart showing the volumes in a grid of numbers.
ClusterChart - the chart showing the volumes in the form of clusters with bar charts.
OptionPositionChart - the graphical component showing the positions and the options Greeks with regard to the underlying instrument. See OptionPositionChart.
Besides that, S# includes two types of charts for the volumes analysis: BoxChart and ClusterChart.
The following figure shows the basic elements of the graphical component.
Chart is the parent container for other elements of the graphical control. It contains methods for adding and removing the "child" elements, properties to customize the appearance of the component and the chart plotting method, as well as the method of charts drawing themselves. Chart can contain several areas (ChartArea) to plot charts (see Figure). Chart also contains the preview area OverView (see Figure). In this area, it is possible to select the chart viewing area using the sliders. In addition, it is possible to scroll and zoom in the chart by means of dragging the ChartArea field, X axis and using the mouse wheel.
The Chart basic properties and methods:
ChartTheme - the component theme.
IndicatorTypes - the list of indicators that can be displayed on the chart.
CrossHair - to enable/disable the crosshair.
CrossHairAxisLabels - to enable/disable the crosshair marks on the axes.
IsAutoRange - to enable/disable the X axis automatic scaling.
IsAutoScroll - to enable/disable the auto scroll on the X axis.
ShowLegend - to enable/disable the legend display.
ShowOverview - to enable/disable the OverView preview area display.
AddArea(ChartArea) - to add ChartArea.
AddElement - to add an item of the data series. It has several overloads.
Reset(IEnumerableIChartElement) - to “reset" the values drawn before.
Draw(ChartDrawData) - to draw the value on the chart.
OrderCreationMode - The order creation mode, when set, allows you to create orders from the chart. Disabled by default.
ChartArea - the plotting area, it is a container for the IChartElement elements (indicators, candles, etc.), which are drawn on the chart and chart axes (ChartAxis).
The ChartArea basic properties:
Elements - the IChartElement elements list.
XAxises - the list of the horizontal axes.
YAxises - the list of the vertical axes.
All the elements that are displayed in the chart must implement the IChartElement interface. S# has the following classes that implement this interface:
ChartCandleElement - the element to display the candles.
ChartIndicatorElement - the element to display the indicators.
ChartOrderElement - the element to display the orders.
ChartTradeElement - the element to display the trades.
The visual elements classes have several properties to customize the appearance of the chart. It is possible to set the color, the lines thickness and the elements style. For example, using the ChartCandleElementDrawStyle property it is possible to change the appearance of the candle (candle or bar). With the ChartIndicatorElementDrawStyle property it is possible to set the indicator line style. So, to display the indicator as a histogram it is necessary to use the ChartIndicatorDrawStylesHistogram value. Properties ChartCandleElementShowAxisMarker and ChartIndicatorElementShowAxisMarker allow to enable/disable the markers display (see Figure) on the chart axes.