Pre loader

Candlestick Chart Coloring



According to the documentation, in FastCandlestickRenderableSeries

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

I would like to ask is there any method to achieve the following:

The candlestick are green in color when Today Close >= Previous Close and red in color when Today Close < Previous Close


  • You must to post comments
Great Answer

Hi Ray,

Unfortunately there is no built-in functionality which allows to do this out of the box. But you can try to use PaletteProvider API and override colors for candles on your own. In this case you’ll need to iterate over points in render pass data and based on its content set desired colors.

I quickly tried to create a prototype of such palette provider so now you have some code to start from:

public class CandlePaletteProvider extends PaletteProviderBase<FastCandlestickRenderableSeries> implements IStrokePaletteProvider, IFillPaletteProvider {

    private final IntegerValues colors = new IntegerValues();

    public CandlePaletteProvider() {

    public void update() {
        final OhlcRenderPassData currentRenderPassData = ((FastCandlestickRenderableSeries<?, ?>) renderableSeries).getCurrentRenderPassData();

        final int pointsCount = currentRenderPassData.pointsCount();

        final int[] colorsItems = colors.getItemsArray();
        final double[] closeValues = currentRenderPassData.closeValues.getItemsArray();

        colorsItems[0] = Color.GREEN;
        for (int i = 1; i < pointsCount; i++) {
            colorsItems[i] = closeValues[i] >= closeValues[i-1] ? Color.GREEN : Color.RED;

    public final IntegerValues getFillColors() {
        return colors;

    public final IntegerValues getStrokeColors() {
        return colors;

Hope this will help you!

In v2.x to make this code working you need to replace this line:

final OhlcRenderPassData currentRenderPassData = ((FastCandlestickRenderableSeries<?, ?>) renderableSeries).getCurrentRenderPassData();

on this line (in v2.x we removed generic params from RenderableSeries so you need to cast render pass data):

final OhlcRenderPassData currentRenderPassData = (OhlcRenderPassData) renderableSeries.getCurrentRenderPassData();

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies