I can't figure out how to make me add an indicator.
I automatically save the series data to localstorage so that I can load it again after reloading the page.
Code: Select all
[
{
"id": "EURUSD_price",
"type": "candlestick",
"name": "Price",
"data": {},
"_colorIndex": 0
},
{
"id": "EURUSD_volume",
"type": "column",
"name": "Volume",
"data": {},
"yAxis": 1,
"_colorIndex": 1
},
{
"linkedTo": "EURUSD_price",
"type": "disparityindex",
"id": "highcharts-rd73r21-766",
"params": {
"index": 3,
"period": 14,
"average": "sma"
},
"yAxis": "highcharts-rd73r21-767",
"_colorIndex": 2,
"_symbolIndex": 0,
"data": {}
}
]
Code: Select all
let ohlc = [],
volume = [],
chart_counter = 0;
for (chart_counter; chart_counter < dataLength; chart_counter += 1)
{
let dd = new Date(data[chart_counter]['time']);
ohlc.push([
dd.getTime(),
data[chart_counter]['open'],
data[chart_counter]['high'],
data[chart_counter]['low'],
data[chart_counter]['close']
]);
volume.push([
dd.getTime(),
data[chart_counter]['volume']
]);
}
chart_obj.addSeries({id: tick_selected+'_price', type: 'candlestick', name: 'Price', data: ohlc});
chart_obj.addSeries({id: tick_selected+'_volume', type: 'column', name: 'Volume', data: volume, yAxis: 1});
UserOptions contains data from localstorage
Code: Select all
userOptions.series.forEach((element, index) =>
{
if (element.linkedTo)
{
if (element.yAxis)
{
chart_obj.addAxis({
id: element.yAxis,
lineWidth: 2,
lineColor: '#08F',
opposite: true
});
}
chart_obj.addSeries({
type: element.type,
linkedTo: ''+element.linkedTo+'',
yAxis: element.yAxis
});
}
});
Help me understand how to do this.
Thanks!