WPF Charting Documentation - SciChart WPF Charts SDK v5.x
The Candlestick charts type

Candlestick charts are provided by the FastCandlestickRenderableSeries type. This accepts data from an OhlcDataSeries (Open, High, Low, Close, Date) and renders candlesticks with optional up/down wick and up/down fill brushes.

NOTE: For info about OhlcDataSeries, as well as other DataSeries types in SciChart, see DataSeries API

To declare a FastCandlestickRenderableSeries, use the following code:

Declare a FastCandlestickRenderableSeries in Xaml / Code Behind

Declare a FastCandlestickRenderableSeries
Copy Code
<!-- where xmlns:s="http://schemas.abtsoftware.co.uk/scichart" -->
<s:SciChartSurface>

    <s:SciChartSurface.RenderableSeries>
       <s:FastCandlestickRenderableSeries x:Name="rSeries" StrokeUp="GreenYellow"
                 StrokeDown="Red"
                 FillUp="#33ADFF2F"
                 FillDown="#33FF0000"
                 StrokeThickness="1"
                 AntiAliasing="False"
                 DataPointWidth="0.8"/>
    </s:SciChartSurface.RenderableSeries>


    <s:SciChartSurface.XAxis>
       <s:CategoryDateTimeAxis/>
    </s:SciChartSurface.XAxis>

    <s:SciChartSurface.YAxis>
       <s:NumericAxis/>
    </s:SciChartSurface.YAxis>

</s:SciChartSurface>

// Code Behind, e.g. in OnLoaded event handler, set the DataSeries
var ohlcDataSeries = new OhlcDataSeries<DateTime, double>();
                                                         
// FastCandlestickRenderableSeries expects data in the formal Date, Open, High, Low, Close              
ohlcDataSeries.Append(new DateTime(2015, 10, 1), 6061.60, 6172.80, 6053.30, 6072.50);
ohlcDataSeries.Append(new DateTime(2015, 10, 2),  6072.50, 6176.20, 6051.60, 6130.00);
ohlcDataSeries.Append(new DateTime(2015, 10, 5), 6130.00, 6301.10, 6130.00, 6298.90);
ohlcDataSeries.Append(new DateTime(2015, 10, 6), 6298.90, 6343.70, 6255.10, 6326.20);
ohlcDataSeries.Append(new DateTime(2015, 10, 7), 6326.20, 6396.30, 6319.80, 6336.40);
ohlcDataSeries.Append(new DateTime(2015, 10, 8), 6336.40, 6380.30, 6303.50, 6374.80);
ohlcDataSeries.Append(new DateTime(2015, 10, 9), 6374.80, 6453.20, 6374.80, 6416.20);
ohlcDataSeries.Append(new DateTime(2015, 10, 12), 6416.20, 6416.20, 6351.30, 6371.20);
ohlcDataSeries.Append(new DateTime(2015, 10, 13), 6371.20, 6371.20, 6303.00, 6342.30);
ohlcDataSeries.Append(new DateTime(2015, 10, 14), 6342.30, 6342.30, 6268.30, 6269.60);
ohlcDataSeries.Append(new DateTime(2015, 10, 15), 6269.60, 6351.40, 6269.60, 6338.70);
ohlcDataSeries.Append(new DateTime(2015, 10, 16), 6338.70, 6398.20, 6338.70, 6378.00);
ohlcDataSeries.Append(new DateTime(2015, 10, 17), 6378.00, 6408.10, 6336.30, 6352.30);

rSeries.DataSeries = ohlcDataSeries;

Declare a FastCandlestickRenderableSeries in Pure Code

Declare a FastCandlestickRenderableSeries
Copy Code
// Declare the scichartsurface
var sciChartSurface = new SciChartSurface();
sciChartSurface.XAxis = new CategoryDateTimeAxis();
sciChartSurface.YAxis = new NumericAxis();
// ...
// Declare and add a Candlestick Series
var candlestickSeries = new FastCandlestickRenderableSeries()
{
    StrokeUp = Colors.GreenYellow,
    FillUp = new SolidColorBrush(Color.FromArgb(0x33, 0xAD, 0xFF, 0x2F)),
    StrokeDown = Colors.Red,
    FillDown = new SolidColorBrush(Color.FromArgb(0x33, 0xFF, 0x00, 0x00)),
    AntiAliasing = false,
    DataPointWidth = 0.8,
    StrokeThickness = 1,
}; sciChartSurface.RenderableSeries.Add(candlestickSeries);

// Set some data
// FastCandlestickRenderableSeries expects data in the formal Date, Open, High, Low, Close  
var ohlcDataSeries = new OhlcDataSeries<DateTime, double>();           
ohlcDataSeries.Append(new DateTime(2015, 10, 1), 6061.60, 6172.80, 6053.30, 6072.50);
ohlcDataSeries.Append(new DateTime(2015, 10, 2),  6072.50, 6176.20, 6051.60, 6130.00);
ohlcDataSeries.Append(new DateTime(2015, 10, 5), 6130.00, 6301.10, 6130.00, 6298.90);
ohlcDataSeries.Append(new DateTime(2015, 10, 6), 6298.90, 6343.70, 6255.10, 6326.20);
ohlcDataSeries.Append(new DateTime(2015, 10, 7), 6326.20, 6396.30, 6319.80, 6336.40);
ohlcDataSeries.Append(new DateTime(2015, 10, 8), 6336.40, 6380.30, 6303.50, 6374.80);
ohlcDataSeries.Append(new DateTime(2015, 10, 9), 6374.80, 6453.20, 6374.80, 6416.20);
ohlcDataSeries.Append(new DateTime(2015, 10, 12), 6416.20, 6416.20, 6351.30, 6371.20);
ohlcDataSeries.Append(new DateTime(2015, 10, 13), 6371.20, 6371.20, 6303.00, 6342.30);
ohlcDataSeries.Append(new DateTime(2015, 10, 14), 6342.30, 6342.30, 6268.30, 6269.60);
ohlcDataSeries.Append(new DateTime(2015, 10, 15), 6269.60, 6351.40, 6269.60, 6338.70);
ohlcDataSeries.Append(new DateTime(2015, 10, 16), 6338.70, 6398.20, 6338.70, 6378.00);
ohlcDataSeries.Append(new DateTime(2015, 10, 17), 6378.00, 6408.10, 6336.30, 6352.30);


candlestickSeries.DataSeries = ohlcDataSeries;

 

NOTE: You can also declare RenderableSeries using full MVVM (series ViewModels). Please see MVVM DataSeries / RenderableSeries API for more details.

 

 

See Also

Stock Charts API

 

 


SCICHART ® is a Registered Trademark in the UK, US and EEC. Copyright SciChart Ltd 2011-2018.

Email us to give feedback!