Search Results for

    Show / Hide Table of Contents

    The Candlestick Series type

    The Candlestick charts are provided by the FastCandlestickRenderableSeries type. This accepts data (X, Open, High, Low, Close) from a OhlcDataSeries<TX,TY> and renders candlesticks at each X-Value coordinate.

    Note

    For more info about OhlcDataSeries<TX,TY>, as well as other DataSeries types in SciChart, see the DataSeries API article.

    Candlestick Series Type

    Note

    Examples of the Candlestick Series can be found in the SciChart Android Examples Suite as well as on GitHub:

    • Native Example
    • Xamarin Example

    The FastCandlestickRenderableSeries is very much alike the FastOhlcRenderableSeries class. It allows to specify FillUp and FillDown brushes, StrokeUp and StrokeDown pens via the following properties:

    • fillUpBrushStyle
    • fillDownBrushStyle
    • strokeUpStyle
    • strokeDownStyle

    StrokeUp and FillUp styles are applied to bars with Close >= Open, and StrokeDown and FillDown to those that have Close < Open respectively.

    Note

    To learn more about Pens and Brushes and how to utilize them, please refer to the PenStyle, BrushStyle and FontStyle article.

    Also, the dataPointWidth specifies how much space a single bar occupies, varying from 0 to 1 (when columns are conjoined).

    Note

    In multi axis scenarios, a series has to be assigned to particular X and Y axes. This can be done by passing the axes IDs to the xAxisId, yAxisId properties.

    Create a Candlestick Series

    To create a Candlestick Series, use the following code:

    • Java
    • Java with Builders API
    • Kotlin
    @Override
    protected void initExample(@NonNull SciChartSurface surface) {
        final IOhlcDataSeries<Double, Double> dataSeries = new OhlcDataSeries<>(Double.class, Double.class);
        dataSeries.append(0.0, 0.0, 1.0, 0.0, 1.0);
        dataSeries.append(1.0, 1.0, 5.0, 0.0, 4.0);
        dataSeries.append(2.0, 3.0, 5.0, 0.0, 0.0);
    
        final FastCandlestickRenderableSeries candlestickSeries = new FastCandlestickRenderableSeries();
    
        candlestickSeries.setDataSeries(dataSeries);
    
        candlestickSeries.setFillDownBrushStyle(new SolidBrushStyle(Color.RED));
        candlestickSeries.setFillUpBrushStyle(new SolidBrushStyle(Color.GREEN));
    
        candlestickSeries.setStrokeDownStyle(new SolidPenStyle(Color.RED, true, 1f, null));
        candlestickSeries.setStrokeUpStyle(new SolidPenStyle(Color.GREEN, true, 1f, null));
    
        UpdateSuspender.using(surface, () -> {
            Collections.addAll(surface.getXAxes(), new NumericAxis(requireContext()));
            Collections.addAll(surface.getYAxes(), new NumericAxis(requireContext()));
    
            Collections.addAll(surface.getRenderableSeries(), candlestickSeries);
        });
    }
    
    @Override
    protected void initExample(@NonNull SciChartSurface surface) {
        final IOhlcDataSeries<Double, Double> dataSeries = sciChartBuilder.newOhlcDataSeries(Double.class, Double.class).build();
        dataSeries.append(0.0, 0.0, 1.0, 0.0, 1.0);
        dataSeries.append(1.0, 1.0, 5.0, 0.0, 4.0);
        dataSeries.append(2.0, 3.0, 5.0, 0.0, 0.0);
    
        final FastCandlestickRenderableSeries candlestickSeries = sciChartBuilder.newCandlestickSeries()
                .withDataSeries(dataSeries)
                .withFillDownColor(Color.RED)
                .withFillUpColor(Color.GREEN)
                .withStrokeDown(Color.RED)
                .withStrokeUp(Color.GREEN)
                .build();
    
        UpdateSuspender.using(surface, () -> {
            Collections.addAll(surface.getXAxes(), sciChartBuilder.newNumericAxis().build());
            Collections.addAll(surface.getYAxes(), sciChartBuilder.newNumericAxis().build());
    
            Collections.addAll(surface.getRenderableSeries(), candlestickSeries);
        });
    }
    
    override fun initExample(surface: SciChartSurface) {
        val candlestickSeries = FastCandlestickRenderableSeries().apply {
            dataSeries = OhlcDataSeries(Double::class.javaObjectType, Double::class.javaObjectType).apply {
                append(0.0, 0.0, 1.0, 0.0, 1.0)
                append(1.0, 1.0, 5.0, 0.0, 4.0)
                append(2.0, 3.0, 5.0, 0.0, 0.0)
            }
    
            fillDownBrushStyle = SolidBrushStyle(Color.RED)
            fillUpBrushStyle = SolidBrushStyle(Color.GREEN)
    
            strokeDownStyle = SolidPenStyle(Color.RED, true, 1f, null)
            strokeUpStyle = SolidPenStyle(Color.GREEN, true, 1f, null)
        }
    
        UpdateSuspender.using(surface) {
            Collections.addAll(surface.xAxes, NumericAxis(context))
            Collections.addAll(surface.yAxes, NumericAxis(context))
    
            Collections.addAll(surface.renderableSeries, candlestickSeries)
        }
    }
    

    Candlestick Series Features

    Candlestick Series also has some features similar to other series, such as:

    • Render a Gap;
    • Draw Series With Different Colors.

    Render a Gap in a Candlestick Series

    It's possible to render a Gap in Candlestick series, by passing a data point with a NaN as the Open, High, Low, Close values. Please refer to the RenderableSeries APIs article for more details.

    Specify Color for Individual Candlesticks

    In SciChart, you can draw each bar of the Candlestick Series with different colors using the PaletteProvider API. To Use palette provider for Candlestick Series - a custom IFillPaletteProvider (or IStrokePaletteProvider) has to be provided to the paletteProvider property. Please refer to the PaletteProvider API article for more info.

    Back to top © 2011-2025 SciChart. All rights reserved. | sitemap.xml