我使用的随机指标是14日移动平均线 . 得到的%k是正确的,但%d不是 . 对于2018年9月14日的aapl,随机指标是58.95和56.3 . 但是,highstock返回的值是44.8和56.3 . 在我的案例中它链接的系列是烛台图表 . 数据包括以毫秒为单位的时间,即开盘价,最高价,最低价和收盘价 .
是否需要设置任何特殊参数才能获得正确的%d?谢谢 .
感谢您的报告 . 不幸的是,你_96429_由计算值od %d 的错误起点引起 . 我刚刚在我们的GitHub存储库中报告了它 . 以下是发布的链接:https://github.com/highcharts/highcharts/issues/8965
%d
在修复之前,您可以应用覆盖 getValues 函数的自定义修复程序 . 这是代码:
getValues
(function(H) { var isArray = H.isArray, SMA = H.seriesTypes.sma, reduce = H.reduce, getArrayExtremes = function (arr, minIndex, maxIndex) { return reduce(arr, function (prev, target) { return [ Math.min(prev[0], target[minIndex]), Math.max(prev[1], target[maxIndex]) ]; }, [Number.MAX_VALUE, -Number.MAX_VALUE]); }; console.log(H.seriesTypes.stochastic.prototype) H.seriesTypes.stochastic.prototype.getValues = function(series, params) { var periodK = params.periods[0], periodD = params.periods[1], xVal = series.xData, yVal = series.yData, yValLen = yVal ? yVal.length : 0, SO = [], // 0- date, 1-%K, 2-%D xData = [], yData = [], slicedY, close = 3, low = 2, high = 1, CL, HL, LL, K, D = null, points, extremes, i; // Stochastic requires close value if ( yValLen < periodK || !isArray(yVal[0]) || yVal[0].length !== 4 ) { return false; } // For a N-period, we start from N-1 point, to calculate Nth point // That is why we later need to comprehend slice() elements list // with (+1) for (i = periodK - 1; i < yValLen; i++) { slicedY = yVal.slice(i - periodK + 1, i + 1); // Calculate %K extremes = getArrayExtremes(slicedY, low, high); LL = extremes[0]; // Lowest low in %K periods CL = yVal[i][close] - LL; HL = extremes[1] - LL; K = CL / HL * 100; xData.push(xVal[i]); yData.push([K, null]); // Calculate smoothed %D, which is SMA of %K if (i >= (periodK - 1) + (periodD - 1)) { points = SMA.prototype.getValues.call(this, { xData: xData.slice(-periodD), yData: yData.slice(-periodD) }, { period: periodD }); D = points.yData[0]; } SO.push([xVal[i], K, D]); yData[yData.length - 1][1] = D; } return { values: SO, xData: xData, yData: yData }; } })(Highcharts)
Live example: http://jsfiddle.net/d4hjmze1/
1 回答
感谢您的报告 . 不幸的是,你_96429_由计算值od
%d
的错误起点引起 . 我刚刚在我们的GitHub存储库中报告了它 . 以下是发布的链接:https://github.com/highcharts/highcharts/issues/8965在修复之前,您可以应用覆盖
getValues
函数的自定义修复程序 . 这是代码:Live example: http://jsfiddle.net/d4hjmze1/