我开发了一个项目,我们使用Highcharts.js / Highstock.js库 . 我使用烛台图表显示VWAP指标(这里是JSFiddle中的示例代码:http://jsfiddle.net/ogorobets/vh3y8195/) .
var ohlc = JSON.parse(ohlcStringified),
volume = JSON.parse(volumeStringified);
Highcharts.stockChart('container', {
chart: {
borderWidth: 1
},
title: {
text: 'Volume Weighted Average Price (VWAP)'
},
legend: {
enabled: true
},
yAxis: [{
height: '60%'
}, {
top: '65%',
height: '35%',
offset: 0
}],
series: [{
type: 'candlestick',
id: 'AAPL',
name: 'AAPL',
data: ohlc,
tooltip: {
valueDecimals: 2
}
}, {
type: 'column',
id: 'volume',
name: 'Volume',
data: volume,
yAxis: 1
}, {
type: 'vwap',
linkedTo: 'AAPL',
showInLegend: true
}]
});
对于此图表,我需要仅显示当天数据的VWAP指标 . 但在官方文档(https://www.highcharts.com/docs/chart-and-series-types/technical-indicator-series)中,我看到我们只能为某个指标设置参数(如EMA指标的'params: {period: 7}'),但我没有找到一个选项来设置我们显示指标的时间段(在我的情况下为VWAP) . 默认行为是显示整个时间轴的指标 . 请告知是否可以设置显示VWAP指标的时间段?
我的意思是我不需要设置可见范围区域,其中指示器用rangeSelector显示为一天 . 但相反,除了当天,我不需要将VWAP指标绘制到其他图表时间轴区域 . 你知道有没有可能用highstock.js开发它?
先感谢您!
1 回答
您的指标库系列包含每分钟的数据 . 为每个基本系列点计算指标点 . 如果您希望每天都有VWAP,则必须提供适当的每日数据 .
作为一种变通方法,您可以添加另一个包含每日数据的系列,使其不可见,并将其用作指标计算的基本系列 . 检查下面发布的示例 .
演示:http://jsfiddle.net/BlackLabel/w1vegobn/