Question

I'm stuck at MACD plotting in highchart.

I don't understand where I'm doing wrong. Please follow jsfiddle link and try to solve and plotting graph for MACD only.

$(function () {
        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            xAxis: {
               type: 'datetime',
            },
            yAxis:  [{ // Primary yAxis for volume
                title: {
                    text: 'volume',
                    style: {
                        color: 'blue'
                    }
                },
                height: '60%',

            },{ // Secondary yAxis for Return
                     height: '60%',
                     opposite: true
            },{
                labels: {
                    align: 'left',
                    x: -3
                },
                title: {
                    text: 'MACD'
                },
                top: '65%',
                height: '35%',
                opposite: true
            }],
               plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            series: [ { color: "blue",
                        data: [0.06694678963061322,0.22184874961635637,1,1.031408464251624,0.6989700043360187,1e-7,0.47712125471966244,1e-7,0.17609125905568124,0.6989700043360187,1e-7,1e-7,1e-7,0.47712125471966244,1e-7,0.47712125471966244,0.0791812460476248],
                        id: "left_bar",
                        name: "Sentiment",
                       type: "column",
                      },{
                        color: "#F09413",
                        data: [50,49.805,50.024142,51.9900907806,54.0333013483,56.1568100913,58.3637727279,60.5991052233,62.7140139956,65.2100317526,68.5422643752,72.0447740848,75.7262620405,80.3758545298,85.3109319979,89.457043293,3.9835696837],
                        id: "right_bar",
                        name: "Price",
                        type: "line",
                        yAxis: 1
                      },{
                        algorithm: "MACD",
                        linkedTo: "right_bar",
                        name: "MACD",
                        showInLegend: true,
                        type: "trendline",
                        yAxis: 1
                     }
                    ]
        });
    });
Was it helpful?

Solution

Accoring to the code: https://rawgit.com/laff/technical-indicators/master/technical-indicators.src.js it looks like periods are hardcoded, so it is a reason why your macd is not calculated. You you no enough points.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top