Highcharts: PSAR and MACD indicators fail with few or no points in main series

Created on 24 May 2018  ·  3Comments  ·  Source: highcharts/highcharts

Expected behaviour

Indicator should not display for series with few points. This is useful for dynamic series.

Actual behaviour

Both PSAR and MACD indicators throw exceptions and fail for series with few points.

Live demo with steps to reproduce

https://jsfiddle.net/wmqq9yob/

Highcharts Stock Bug

Most helpful comment

Oh, SMA accidentally works fine.. It looks like during transition/refactoring from Indicator class to Series this safeguard was removed.

All 3 comments

Thanks for reporting!

This is result of using less points than params.longPeriod+params.signalPeriod (defaults to 26+9-current point). I see two solutions:

  • throw an error (H.error(), or maybe H.warn()?) that we have less points than needed
  • gracefully do nothing and wait for more points, users can be surprised and confused that they don't see indicator series

What do you think @oysteinmoseng , @TorsteinHonsi ?

I think gracefully do nothing, that's what the other indicators do (e.g. sma). Or alternatively return null or 0 points. It's useful to not throw an error for this, as the data might be dynamic.

Oh, SMA accidentally works fine.. It looks like during transition/refactoring from Indicator class to Series this safeguard was removed.

Was this page helpful?
0 / 5 - 0 ratings