index.htm
3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Highstock Example</title>
<style type="text/css">
</style>
</head>
<body>
<script src="../../code/highstock.js"></script>
<script src="../../code/modules/data.js"></script>
<script src="../../code/modules/drag-panes.js"></script>
<script src="../../code/modules/exporting.js"></script>
<script src="../../code/indicators/indicators.js"></script>
<script src="../../code/indicators/volume-by-price.js"></script>
<div id="container" style="height: 500px; min-width: 310px"></div>
<script type="text/javascript">
Highcharts.getJSON('https://www.highcharts.com/samples/data/aapl-ohlcv.json', 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
Highcharts.stockChart('container', {
rangeSelector: {
selected: 2
},
title: {
text: 'AAPL Historical'
},
subtitle: {
text: 'With SMA and Volume by Price technical indicators'
},
yAxis: [{
startOnTick: false,
endOnTick: false,
labels: {
align: 'right',
x: -3
},
title: {
text: 'OHLC'
},
height: '60%',
lineWidth: 2,
resize: {
enabled: true
}
}, {
labels: {
align: 'right',
x: -3
},
title: {
text: 'Volume'
},
top: '65%',
height: '35%',
offset: 0,
lineWidth: 2
}],
tooltip: {
split: true
},
plotOptions: {
series: {
dataGrouping: {
units: groupingUnits
}
}
},
series: [{
type: 'candlestick',
name: 'AAPL',
id: 'aapl',
zIndex: 2,
data: ohlc
}, {
type: 'column',
name: 'Volume',
id: 'volume',
data: volume,
yAxis: 1
}, {
type: 'vbp',
linkedTo: 'aapl',
params: {
volumeSeriesID: 'volume'
},
dataLabels: {
enabled: false
},
zoneLines: {
enabled: false
}
}, {
type: 'sma',
linkedTo: 'aapl',
zIndex: 1,
marker: {
enabled: false
}
}]
});
});
</script>
</body>
</html>