bvanseghi
Posts: 2
Joined: Tue Jul 06, 2021 2:54 am

Multi-line series data on a custom indicator

Hello!

My goal is pretty straightforward, I want to implement a custom indicator which displays multiple horizontal lines for an ohlc chart, like resistance/support levels.

Creating a single line is simple enough according to this documentation https://www.highcharts.com/docs/stock/c ... indicators, but there doesn't seem to be a resource for multiple lines from a single indicator. Any suggestions?
pawelys
Posts: 962
Joined: Wed Sep 02, 2020 10:37 am

Re: Multi-line series data on a custom indicator

Hello, welcome to the official highcharts forum, and thanks for contacting us with your question! We are currently in the process of creating the documentation of creating your own custom indicators with multiple lines. Currently there are some indicators, that use multiple lines, and you can check how they are implemented on our github page (or clone our repo and check in locally on your machine). Here is the example of the multi line indicator: https://github.com/highcharts/highchart ... or.ts#L171

I will let you know, when article about creating multiple lines indicator will be published, and sorry that it isn't already out in public! :)

Kind regards,
Paweł Lysy
Highcharts Developer
bvanseghi
Posts: 2
Joined: Tue Jul 06, 2021 2:54 am

Re: Multi-line series data on a custom indicator

pawelys wrote: Wed Jul 07, 2021 8:51 am Hello, welcome to the official highcharts forum, and thanks for contacting us with your question! We are currently in the process of creating the documentation of creating your own custom indicators with multiple lines. Currently there are some indicators, that use multiple lines, and you can check how they are implemented on our github page (or clone our repo and check in locally on your machine). Here is the example of the multi line indicator: https://github.com/highcharts/highchart ... or.ts#L171

I will let you know, when article about creating multiple lines indicator will be published, and sorry that it isn't already out in public! :)

Kind regards,

Thank you for the response. I have taken a look at the BBIndicator that you linked, and it seems as if it's getValues function is similar to the getValues function in Highcharts.seriesType as outlined in the documentation here: https://www.highcharts.com/docs/stock/c ... indicators

I have taken the AAPL Linear Regression jsfiddle example and altered it to what I believe is a similar configuration to the BBIndicator code that was linked in your reply. Here is the jsfiddle of the modified example: https://jsfiddle.net/Lmenvsap/1/

Despite having similar code to the BBIndicator, the chart in the linked jsfiddle fails to render the second line. The chart makes space to accommodate where the second line should be, but the line itself does not appear. Why is this so, and how can it be fixed?
rafalS
Posts: 2665
Joined: Thu Jun 14, 2018 11:40 am

Re: Multi-line series data on a custom indicator

Hi @bvanseghi,

To create a multiple-line indicator, you need to use our MultipleLinesMixin. Then, you need to add some extra prototype members:

Code: Select all

pointArrayMap: ['y', 'y2'],
    parallelArrays: ['x', 'y', 'y2'],
    pointValKey: 'y',
    linesApiNames: ['extraLine'],

    drawGraph: multipleLinesMixin.drawGraph,
    getTranslatedLinesNames: multipleLinesMixin.getTranslatedLinesNames,
    translate: multipleLinesMixin.translate,
    toYData: multipleLinesMixin.toYData

Here is a working demo showing all of the above (MultipleLinesMixin attached in the HTML section): https://jsfiddle.net/BlackLabel/jxf19c4d

Let me know if you have any further questions.

Best regards!
Rafal Sebestjanski,
Highcharts Team Lead

Return to “Highcharts Stock”