orion176
Posts: 1
Joined: Fri Oct 28, 2022 8:20 am

Custom Indicator on Candlestick chart

Hello

I'm trying to create a custom indicator. It seems to work fine on a line chart, but when I use a candlestick chart nothing renders.

The issue can be reproduced here:

https://jsfiddle.net/gh/get/library/pur ... sion-aapl/

Adding type: 'candlestick' as per below will cause the chart to not render, but when setting it to 'line' works fine.

Code: Select all

series: [{
            id: 'aapl',
            type: 'candlestick',
            name: 'AAPL Stock Price',
            data: data
        }, {
            type: 'linearregression',
            linkedTo: 'aapl'
        }]
Any suggestions about how to get custom indicators to work with candlestick charts would be much appreciated.

Thanks!
kamil.k
Posts: 458
Joined: Thu Oct 06, 2022 12:49 pm

Re: Custom Indicator on Candlestick chart

Hello orion176,

Welcome to our forum and thanks for contacting us with your question.

The indicators work fine but the problem lies in the data you provided for the series. For the line type, you have to provide an array of arrays with 1/2 values but for the candlestick type, you need an array of arrays with 4/5 values. That's why the candlestick is not showing up. The solution is as simple as changing the data structure for each type.

I have updated your demo with the constant data for the candlestick type for better visualization, see:
https://jsfiddle.net/BlackLabel/yp8c5720/

API: https://api.highcharts.com/highstock/se ... stick.data

Feel free to ask any further questions.

Best regards!
Kamil Kubik
Highcharts Developer

Return to “Highcharts Stock”