如何在Highstock中包含多个指标

时间:2018-03-25 08:50:54

标签: highcharts highstock candlestick-chart

我有两个问题:

  • 1)我想用音量显示我的蜡烛图表,以及下面的更多指标(rsi,macd,adx ......),如下例所示,但不使用blacklabel插件

JSFiddle link

(function () {
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlcv.json&callback=?', function (data) {

        // split the data set into ohlc and volume
        var ohlc = [],
            volume = [],
            dataLength = data.length,
            // set the allowed units for data grouping
            groupingUnits = [[
                'week',                         // unit name
                [1]                             // allowed multiples
            ], [
                'month',
                [1, 2, 3, 4, 6]
            ]],

            i = 0;

        for (i; i < dataLength; i += 1) {
            ohlc.push([
                data[i][0], // the date
                data[i][1], // open
                data[i][2], // high
                data[i][3], // low
                data[i][4] // close
            ]);

            volume.push([
                data[i][0], // the date
                data[i][5] // the volume
            ]);
        }


        // create the chart
        $('#container').highcharts('StockChart', {

            rangeSelector: {
                selected: 1
            },

            title: {
                text: 'AAPL Historical'
            },

            yAxis: [{
                labels: {
                    align: 'right',
                    x: -3
                },
                title: {
                    text: 'OHLC'
                },
                height: '60%',
                lineWidth: 2
            }, {
                labels: {
                    align: 'right',
                    x: -3
                },
                title: {
                    text: 'Volume'
                },
                top: '65%',
                height: '35%',
                offset: 0,
                lineWidth: 2
            }],

            indicators: [{
                id: "AAPL",
                type: "rsi"
            }],

            series: [{
                type: 'candlestick',
                name: 'AAPL',
                id: "AAPL",
                data: ohlc,
                dataGrouping: {
                    units: groupingUnits
                }
            }, {
                type: 'column',
                name: 'Volume',
                data: volume,
                yAxis: 1,
                dataGrouping: {
                    units: groupingUnits
                }
            }]
        });
    });
});

这是否可以使用highstock甚至与highchart结合使用?

老实说,我不需要用任何插件来计算指标,我自己做了,我只需要代表它们。

  • 2)是否可以以某种方式将值传递给高价指标?

0 个答案:

没有答案