Pre loader

How to customize Candle Stick Style

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hi,
I want to customize the style of stick such that
1. Green and hollow stick if it is rising and open higher than close
2. Green and fill stick if it is rising and open lower than close
3. Red and hollow stick if it is falling and open higher than close
4. Red and fill stick if it is falling and open lower than close

How could i achieve that with only one candle series?

Version
Trial
  • You must to post comments
0
0

Hi Tommy,

I believe you can do achieve this by using our PaletteProvider API.

I’m not sure what do you mean by ‘rising stick’ but you can use next code as base for your palette provider:

  private static class CandleStickPaletteProvider extends PaletteProviderBase<FastCandlestickRenderableSeries> implements IStrokePaletteProvider, IFillPaletteProvider {
    private final IntegerValues fillColors = new IntegerValues();
    private final IntegerValues strokeColors = new IntegerValues();

    public CandleStickPaletteProvider() {
        super(FastCandlestickRenderableSeries.class);
    }

    @Override
    public IntegerValues getFillColors() {
        return fillColors;
    }

    @Override
    public IntegerValues getStrokeColors() {
        return strokeColors;
    }

    @Override
    public void update() {
        final OhlcRenderableSeriesBase renderableSeries = this.renderableSeries;
        final OhlcRenderPassData currentRenderPassData = (OhlcRenderPassData) renderableSeries.getCurrentRenderPassData();

        final int size = currentRenderPassData.pointsCount();
        fillColors.setSize(size);
        strokeColors.setSize(size);

        final int[] fillColorsArray = fillColors.getItemsArray();
        final int[] strokeColorsArray = strokeColors.getItemsArray();

        final double[] openValues = currentRenderPassData.openValues.getItemsArray();
        final double[] closeValues = currentRenderPassData.closeValues.getItemsArray();
        final double[] highValues = currentRenderPassData.highValues.getItemsArray();
        final double[] lowValues = currentRenderPassData.lowValues.getItemsArray();

        for (int i = 0; i < size; i++) {
            final double closeValue = closeValues[i];
            final double openValue = openValues[i];

            final boolean up = closeValue >= openValue;
            final boolean isRising = closeValue >= openValue;

            strokeColorsArray[i] = up ? Color.GREEN : Color.RED;
            fillColorsArray[i] = isRising ? strokeColorsArray[i] : Color.TRANSPARENT;
        }

    }
}

Is this suitable for your needs?

Best regards,
Yura

  • tommy ng
    Thanks!!! It works
  • 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