blacklabel / indicators

Indicators plugin for Highstock by Black Label
http://blacklabel.github.io/indicators/
Other
35 stars 12 forks source link

ATR/RSI cannot display if series.type is 'line' #46

Closed PhilTheAir closed 8 years ago

PhilTheAir commented 8 years ago

ATR/RSI cannot display if series.type is 'line / kagi / spline / area / area range / area spline range'.

For example, In the line 72 in the demo : http://jsfiddle.net/RE7sS/205/, the code below: adv_options.series[0].type = 'candlestick'; When change the value 'candlestick' to 'line' in the code above, the two button ('RSI' and 'ATR') in the result page will not work.

In normal conditions every element in the array 'series.yData' should be another array with 4 values. But in these cases above ( e.g. when the type of series is line ) the elements in the array 'series.yData' are just plain numbers ( see official API : series.data doesn't contain all the points. It only contains the points that have been created on demand......Additionally, 'series.options.data' contains all configuration objects for the points ).

So additional function 'properYData(series)' is added utilizing the variable 'series.options.data' to deal with this problem and return the correct yData array.

PhilTheAir commented 8 years ago

Second commit for this pull is for not affect 'sma' and 'ema' indicators.

pawelfus commented 8 years ago

Thank you for your contribution! Unfortunately I can not merge this pull request. I think this should be fixed on the indicator level.

Let me explain. As you noticed, it doesn't make sense to add this logic for SMA/EMA, and I don't like the idea for comparing rsi and atr - there is more indicators which require such improvement. Also, what will happen when user will use simple line series with just one y-value, not as like in the demo four values? I think there will be another issue with point objects ({low: value, high: value, close: value, open: value, x: timestamp} instead of [timestamp, value, value, value, value]).