Git Product home page Git Product logo

indicators's Introduction

#f03c15 We encourage you to use Highstock 6+ as it has a vast range of technical analysis indicators build in. This plugin was build for older versions of Highstock

Indicators - Highstock module

Indicators available in this plugin: SMA, EMA, ATR, RSI. You can use these indicators for free.

We also have other indicators available: Bollinger Bands, MACD, Momentum, CCI, Stochastic, Rate of Change (ROC), Accumulation / distribution (AD), Pivot Points, ZigZag, Weighted Moving Average (WMA), PSAR, MFI, Price Envelopes.
If you're are interested in purchasing them, developing new indicators or any other tools, please contact us at: [email protected]

You may also want to check our other demo here: http://demo.blacklabel.pl.

Go to project page to see this module in action: http://blacklabel.github.io/indicators/

Requirements

  • Version 2.0+ requires the latest Highstock (v2.1.5+)
  • Version 1.1 requires Highstock v2.1.5
  • Version <1.1 supported since Highstock v1.3.9 to Highstock v2.1.4

Versions

  • 2.x - Improved logic for calculations and performance. Values are based on initial points, not grouped. When points are grouped by dataGrouping then indicators values are grouped too.
  • 1.x - Initial version of Indicators.js. Calculations are based on grouped points (aka dataGrouping)

Installation

  • Like any other Highcharts module (e.g. exporting), add <script> tag pointing to indicators.js below Highcharts script tag. Then attach all required indicators (like ema.js, rsi.js).

  • For NPM users:

var Highcharts = require('highcharts/highstock');
    require('indicators')(Highcharts);
    require('sma')(Highcharts);
    require('ema')(Highcharts);
    require('rsi')(Highcharts);
    require('atr')(Highcharts);
  • For BOWER users:
bower install highcharts-indicators

Code

The latest code is available on github: https://github.com/blacklabel/indicators/

Usage and demos

indicators: [{
            id: 'AAPL',
            type: 'sma',
            params: {
                period: 5,
            },
            tooltip:{
                pointFormat: '<span style="color: {point.color}; ">pointFormat SMA: </span> {point.y}<br>'
            },
        }, {
            id: 'AAPL',
            type: 'ema',
            params: {
                period: 5,
                index: 0
            },
            styles: {
                strokeWidth: 2,
                stroke: 'green',
                dashstyle: 'solid'
            }
        }, {
            id: 'AAPL',
            type: 'atr',
            params: {
                period: 14,
            },
            styles: {
                strokeWidth: 2,
                stroke: 'orange',
                dashstyle: 'solid'
            },
            yAxis: {
                lineWidth:2,
                title: {
                    text:'My ATR title'
                }
            }   
        }, {
            id: 'AAPL',
            type: 'rsi',
            params: {
                period: 14,
                overbought: 70,
                oversold: 30
            },
            styles: {
                strokeWidth: 2,
                stroke: 'black',
                dashstyle: 'solid'
            },
            yAxis: {
                lineWidth:2,
                title: {
                    text:'My RSI title'
                }
            }   
}],
tooltip:{
    enabledIndicators: true
},

Parameters

Property Type Description
idStringid of series
typeStringtype of indicator (one of: sma, ema, atr, rsi)
showInLegendBooleandetermines if indicator should be visible in the legend. Defaults to false.
nameStringname is used in legend and tooltip to display indicator. By default it's the same as type.
stylesObjectcolor, dashstyle, width etc. for a indicator line
yAxis (ATR/RSI)ObjectyAxis object like in Highcharts, options for additional yAxis
paramsObjectconfig options for indicator
params.approximation (SMA/EMA/ATR/RSI)String/FunctionThe same property as in dataGrouping.approximation for Highstock. Supported since version 2.0.0. Defaults to "average".
params.period (SMA/EMA/ATR/RSI)Numberbase period for indicator (it's number of points to be calculated). Defaults to 14.
params.index (SMA/EMA)Numbery-value index. Useful when using candlestick/ohlc/range series to determine which value (open/high/low/close) should be used in indicator. Defaults to 0.
params.overbought (RSI)Numberoverbought value between 0-100. Defaults to 70.
params.oversold (RSI)Numberoversold value between 0-100. Defaults to 30.
tooltip.pointFormat String point.color and point.y return values from indicator. Disabled by default.

###New options/methods in Chart:

Method Version: Description
chart.addIndicator(options, [redraw]) v 1.0.0+ Add new indicator with given options. Optionally redraw chart.
chart.indicators.allItems v 1.0.0+ Array containing all indicators.
chart.alignAxes v 1.0.9+ true/false. When idicator requires separate yAxis (like ATR or RSI) then indicators plugin will update heights of the axes to fit plotting area. Disable it and set yAxis.top and yAxis.height when you want different heights for the y-axes. Defaults to true. Note: When disabled, top and height options need to be set for all axes for better view.
tooltip.enabledIndicators v 1.0.0+ true/false, show indicators in tooltip. Disabled by default.
Highcharts.approximations v 2.0.0+ Object containing built-in approximations (functions) in Highstock. For more details see dataGrouping.approximation

###Indicator object

Method Description
indicator.update(options) Update indicator with given options
indicator.destroy() Destroy indicator
indicator.setVisible(true|false) Hide or show indicator.

indicators's People

Contributors

morganfree avatar omrigilad avatar pawelfus avatar sebastianbochan avatar vinilzen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

indicators's Issues

Missing configurable decimal for indicator tooltip value in latest update

In previous versions we have "series.options.tooltip.valueDecimals" which sets decimal value for indicators for tooltip i,e precision provided by user or 5 by default.

In current lib it is hardcoded to 3 "HC.numberFormat(val.y, 3)" Line no 335 of indicators.js, can anyone help us on this? Or is there any way to configure?

Setting indicator height

Is there a way to specify the heigh of an idicator. Can't find any in the API. Is there some undocumented function I could call to achieve it?

Indicators update axes unnecessary

Compare examples:

Indicators shouldn't update axes when it's not necessary. Performance and logic issue.

Internal note:
It may be necessary to create logic when chart contains more than default one yAxis. Consider example when two y-axes are set (height: "65%" + height: "35%") and we need to add new yAxis for an indicator. Right now all axes will get the same height, calculated in var newHeight = chart.updateHeightAxes(diff, add); method.

It may be good idea to check if options are set in userOptions or calculated by Highcharts source.

Multiple indicators with the same type

When using multiple indicators, but the same type on one series it will be broken, for example SMA30 and SMA15 -> in point.indicators.indicator_name[index] we will get only one indicator (because key is sma). The indicator_name should be replaced with a better key, or simply make this an array, not a literal object.

RSI algorithm

We need to revise the algorithm. It looks like using old version, not EMA based.

Series.update() removes indicators

Series.update() in fact removes series then adds new one. Problem comes when we loop over indicators and removes element from the array. We need to loop as decrementing it's index, not incrementing.

Culprit in line #97.

What's the licence

Hey

I see this is licenced under creative commons, however which creative commons licence is it licenced with?

Update indicators

No options are applied. Only when we call update() and redrawIndicators(), then styles options are applied, but not logic, like period.

Issue while updating series from 'CandleStick' to 'Line'

Hello Team,

We already raised issue to Support team and got reply with below GitHub link
highcharts/highcharts#2322

But still We are facing issue while updating series from 'Candlestick' to 'Line' and again from 'Line' to 'Line'.

Below are the exact steps to replicate issue.
Click on JsFiddle - http://jsfiddle.net/BDChaudhari90/97651yvn/10/

  1. Here the chart will be loaded with candlestick type initially.
  2. Now change it to Line by clicking on "change to line" button. (Chart will be changed to line.)
  3. Now click on 'Again change to Line' button. (This is causing issue.)
  4. Now again change to candlestick it will work.

If above GitHub link is the workaround for the same then how can we replace all the methods of the prototype object ?

enabledIndicators doesn't use tooltip.pointFormat

Example:

                    tooltip:{
                        shared: false,
                        enabledIndicators: true,
                        followPointer: false,
                        backgroundColor: 'white',
                        borderWidth: 0,
                        borderRadius: 0,
                        headerFormat: '{point.key} ',
                        pointFormat: ' | <span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b>',
                        positioner: function(p,w,h) {
                                return {
                                        x: 70,
                                        y: 50
                                }
                        }
                    },

Add a "name" option for the label

Split from #6.

this.name = options.type;

This line sets the name to options.type which does not support internationalization or even english human-friendly names. Setting it to options.name by default and a fallback to options.type would help a lot.

The suggested labelFormatter solution changes all the labels, not just the one.

Using the legend?

The Technical Indicators plugin shows the trendlines in the legend which allows hiding the trendlines and/or the data lines exclusively from each other. Is this possible?

Updated for highstock 2.0

I am using high-stock 2.0.4 in my project. Is the project in development ? Is it safe to use for highstock 2.0 ?

Tooltip.pointFormat and Tooltip.formatter

Current solution for tooltip.enabledIndicators needs to be refactored. Issues:

  • tooltip.pointFormat is not respected at all
  • in tooltip.formatter we have no easy access to indicator object, under point.indicators.indicator_name[index] we have only x+y values, a reference to the indicator would be great, to get color, names etc.

indicator.destory() not working after modifying yAxis.

On updating yAxis indicator.destroy() not working...

Steps to replicate issue.

  1. Add an indicator which have separate yAxis. (i.e - RSI / ATR..)

  2. Now update yAxis where indicator belongs. (i.e Chart.yAxis[2].update({top:'20%'});)

  3. Now redraw graph so that Indicator will be displayed on updated yAxis.
    Chart.indicators.allItems[0].drawGraph();

  4. Now try to destroy that Indicator using indicator.destroy() (It will not work)
    Chart.indicators.allItems[0].destroy();

Indicator will be destroyed but yAxis will be there....

bower.json

Add the bower.json file and update README.md

Tooltip doesnot show up while dynamic loading of data

i have implemented setextreme and load data whenever extremes are changed and set the new data in series . when i add the new data i can see the SMA line but tooltip doesnt shows the SMA header while initially i can see it.

Do i need to do some extra setting for that.???

updateHeightAxes removes animation

For example when updating point, animation is ignored.

In the fact, updateHeightAxes should be called only when rendering new indicator, or when updating existing one.

Resizing chart won't redraw panes

Simply resize chart.
Workaround: After setting new size, call:

chart.setSize(width, height, false);
chart.updateHeightAxes(20, false, false);
chart.redraw();

data lost

data lost when drag the scrollbar

try this code:

<script src="http://cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>

<script src="http://cdn.bootcss.com/highstock/2.1.5/highstock.js"></script>

<script src="http://www1.glaucusis.com/assets/js/indicators/indicators.js"></script>

<div class="charts" id="charts"></div>

<script type="text/javascript">
$(function () {
        var data = [[1399248000000,1300.19,1315.74,1299.3,1310.3,291075,50],[1399334400000,1310.16,1314.22,1304.35,1308.19,269768,43.333333333333],[1399420800000,1308,1314.7,1286.67,1290.01,311151,60],[1399507200000,1289.92,1295.45,1285.2,1289.35,263097,60],[1399593600000,1289.34,1294.54,1285.47,1288.7,293450,50],[1399852800000,1289.08,1303.91,1277.83,1295.85,326103,0],[1399939200000,1295.97,1298.9,1289.14,1293.56,309530,60],[1400025600000,1293.64,1309.17,1291.2,1305.92,346649,40],[1400112000000,1305.94,1307.29,1291.03,1296.21,332587,51.666666666667],[1400198400000,1296.12,1298.36,1287.92,1293.45,303612,46.666666666667],[1400457600000,1293.45,1305.65,1289.44,1293.22,307995,40],[1400544000000,1293.11,1296.98,1286.04,1294.22,309045,60],[1400630400000,1294.22,1296.36,1283.1,1291.95,318233,54],[1400716800000,1291.95,1303.85,1289.7,1294.09,322636,46.666666666667],[1400803200000,1293.95,1295.7,1286.78,1292.63,293138,43.333333333333],[1401062400000,1292.51,1294.73,1290.6,1292.18,146253,0],[1401148800000,1292.18,1293.55,1264.3,1264.67,336747,52.380952380952],[1401235200000,1264.9,1267.3,1256.03,1258.08,346841,56],[1401321600000,1258.23,1260.52,1251.45,1255.66,312664,40],[1401408000000,1255.77,1260.56,1242.31,1249.61,294143,50],[1401667200000,1249.48,1250.92,1241.03,1243.92,277890,44],[1401753600000,1243.88,1247.84,1240.6,1245.06,282415,42],[1401840000000,1244.5,1249.26,1242.6,1243.95,310417,60],[1401926400000,1243.95,1257.75,1241.1,1253.67,343342,45],[1402012800000,1253.75,1257.92,1245.9,1253.15,317905,45],[1402272000000,1252.57,1257.23,1251.2,1252.19,276697,50],[1402358400000,1251.8,1263.79,1249.9,1259.85,286233,53.333333333333],[1402444800000,1259.9,1265.37,1257.9,1261.09,282708,52.5],[1402531200000,1260.5,1274.96,1259.4,1273.33,313124,52.5],[1402617600000,1273.41,1278.06,1270.79,1277.28,334638,47.333333333333],[1402876800000,1277.3,1285.13,1270.2,1272.12,340831,50],[1402963200000,1272.02,1273.41,1258.67,1270.69,316065,46],[1403049600000,1270.61,1278.62,1266.27,1277.2,341133,47.333333333333],[1403136000000,1277.72,1321.72,1275.5,1320.04,367774,53.333333333333],[1403222400000,1320.35,1322.08,1306.46,1314.3,384250,40],[1403481600000,1315.31,1318.66,1309.7,1317.49,289788,41.333333333333],[1403568000000,1317.45,1326.09,1313.5,1318.13,327341,55],[1403654400000,1318.36,1325.01,1307.47,1319.19,323130,45],[1403740800000,1319.25,1320.02,1306.29,1316.46,324578,45],[1403827200000,1316.2,1322.44,1312.67,1316.48,260988,50],[1404086400000,1315.76,1329.65,1310.31,1327.44,319826,53.333333333333],[1404172800000,1327.21,1332.93,1323.71,1326.35,338763,60],[1404259200000,1326.57,1332.06,1321.32,1326.84,312166,41.666666666667],[1404345600000,1326.83,1327.62,1309.71,1319.62,319876,60],[1404432000000,1319.47,1323.38,1318.2,1320.93,179404,50],[1404691200000,1320.78,1321.23,1311.5,1319.96,304359,50],[1404777600000,1319.93,1325.03,1313.42,1319.26,312010,47.777777777778],[1404864000000,1319.26,1332.39,1317.5,1327.81,331164,55],[1404950400000,1327.73,1344.95,1324.24,1335.85,319493,47.5],[1405036800000,1335.75,1339.36,1333.81,1338.35,265387,60],[1405296000000,1338.05,1339.77,1302.8,1307.18,313323,52.777777777778],[1405382400000,1307.25,1313.89,1292.1,1294.13,289188,48.333333333333],[1405468800000,1294.07,1303.9,1293.22,1299.26,319115,53.333333333333],[1405555200000,1299.32,1324.16,1297.3,1319.09,333798,45],[1405641600000,1319.31,1324.85,1304.58,1310.2,332119,60],[1405900800000,1310.31,1318.74,1307,1312.52,298042,40],[1405987200000,1312.45,1315.24,1302,1306.49,308926,48],[1406073600000,1306.38,1311.45,1303.12,1304.89,291457,40],[1406160000000,1304.64,1305.4,1287.65,1293.72,321997,52.25],[1406246400000,1293.88,1308.79,1290.5,1307.5,298364,51.666666666667],[1406505600000,1307.34,1309.46,1301,1304.15,319174,53.75],[1406592000000,1303.6,1312.28,1296.1,1298.95,312269,43.125],[1406678400000,1299.15,1303.77,1291.89,1296.18,296567,50],[1406764800000,1296.35,1297.48,1280.7,1282.71,310966,42.857142857143],[1406851200000,1282.68,1297.31,1280.54,1293.9,301757,40],[1407110400000,1293.41,1295.63,1286.06,1288.22,267752,53.333333333333],[1407196800000,1287.8,1294.09,1282.6,1288.77,298803,48.888888888889],[1407283200000,1288.8,1309.58,1287.3,1305.91,326051,40],[1407369600000,1306.2,1314.65,1302.07,1312.1,330519,49.5],[1407456000000,1312.65,1322.89,1306.05,1309.9,364429,52.5],[1407715200000,1309.58,1311.65,1304.8,1308.53,281497,47.777777777778],[1407801600000,1308.55,1317.94,1305.65,1309.42,280403,53.75],[1407888000000,1309,1315.16,1304.85,1312.94,260316,50],[1407974400000,1312.85,1319.49,1308.84,1313.45,265362,46],[1408060800000,1313.48,1315.27,1292.58,1304.85,288168,57.083333333333],[1408320000000,1304.8,1304.8,1295.65,1298.53,257726,40],[1408406400000,1298.52,1302.48,1293.85,1295.56,242940,40],[1408492800000,1295.72,1298.14,1287.89,1291.84,268260,43.333333333333],[1408579200000,1291.91,1292.02,1273.1,1276.71,285276,60],[1408665600000,1276.74,1283.1,1274.26,1280.81,257009,50],[1408924800000,1281.1,1281.7,1274.32,1276.87,210539,50],[1409011200000,1276.81,1291.08,1275.53,1281.66,287012,50],[1409097600000,1281.16,1287.49,1280.18,1282.88,256074,0],[1409184000000,1282.61,1296.65,1282.31,1289.52,307610,43.75],[1409270400000,1289.61,1291.52,1283.37,1287.27,247081,55],[1409529600000,1287.32,1290.07,1284.93,1287.14,163357,46.666666666667],[1409616000000,1287.12,1287.73,1262.54,1265.38,299235,52.222222222222],[1409702400000,1265.25,1271.55,1261.35,1269.33,284687,55.833333333333],[1409788800000,1269.36,1277.39,1260.65,1261.58,303750,48.333333333333],[1409875200000,1261.73,1273.77,1257.31,1268.98,285912,50],[1410134400000,1268.59,1271.97,1251.54,1255.29,270631,46.666666666667],[1410220800000,1255.43,1258.36,1247.5,1255.38,298590,46.666666666667],[1410307200000,1255.53,1257.95,1243.89,1249.62,276554,55.833333333333],[1410393600000,1249.76,1250.35,1235.04,1240.81,295088,51.666666666667],[1410480000000,1240.97,1241.79,1227.65,1229.42,300986,51],[1410739200000,1229.57,1238.69,1225.68,1233.5,295479,40],[1410825600000,1233.42,1242.15,1231.79,1235.62,321868,45.512820512821],[1410912000000,1235.61,1239.61,1221.52,1223.43,314238,48.636363636364],[1410998400000,1223.55,1228.01,1215.89,1224.92,339092,55],[1411084800000,1225.15,1228.95,1213.88,1215.98,334503,0],[1411344000000,1215.03,1220.53,1208.32,1214.98,328390,53.333333333333],[1411430400000,1215.03,1235.62,1214.19,1223.39,262889,47.5],[1411516800000,1223.45,1226.16,1215.79,1217.06,268960,54],[1411603200000,1217.06,1224.59,1207.02,1221.45,307519,45],[1411689600000,1221.61,1231.43,1212.44,1218.28,307675,52.222222222222],[1411948800000,1217.89,1223.45,1214.99,1215.97,323135,60],[1412035200000,1215.95,1220.24,1204.55,1208.26,337904,50],[1412121600000,1208.23,1219.48,1204.72,1213.82,336127,41.212121212121],[1412208000000,1213.81,1222.48,1208.83,1214.55,334486,46],[1412294400000,1214.49,1215.48,1190.06,1191.76,292950,41.481481481481],[1412553600000,1191.06,1209.09,1183.09,1207.05,330655,42.666666666667],[1412640000000,1207.25,1213.59,1202.95,1208.91,329841,40],[1412726400000,1208.95,1224.27,1205.02,1221.09,356927,58],[1412812800000,1221.18,1233.49,1218.99,1224.24,346200,50],[1412899200000,1224.45,1225.66,1217.4,1223.17,300898,40],[1413158400000,1222.72,1237.9,1222.72,1235.8,337418,53.333333333333],[1413244800000,1235.87,1238.31,1231.08,1232.53,344003,51.666666666667],[1413331200000,1232.78,1249.73,1221.93,1241.97,364333,50],[1413417600000,1242.01,1245.31,1235.74,1238.97,398417,55],[1413504000000,1239.11,1241.89,1231.77,1238.43,336559,45],[1413763200000,1238.49,1248.79,1234.63,1246.86,280674,50],[1413849600000,1246.9,1255.32,1245.39,1248.95,306886,53.333333333333],[1413936000000,1248.65,1249.94,1240.55,1241.46,286553,50],[1414022400000,1241.22,1244.8,1226.38,1231.81,299741,40],[1414108800000,1231.85,1234.37,1229,1231.04,272953,50],[1414368000000,1231.05,1232.12,1225.55,1226.43,230457,60],[1414454400000,1226.64,1235.75,1222.56,1228.57,309715,50.47619047619],[1414540800000,1228.57,1230.73,1208.47,1212.22,270186,48.095238095238],[1414627200000,1212.2,1216.85,1196.03,1198.86,347956,43.333333333333],[1414713600000,1198.86,1202.91,1161.31,1173.23,378942,41.333333333333],[1414972800000,1171.46,1173.98,1161.75,1165.5,328097,44.444444444444],[1415059200000,1165.57,1175.01,1163.96,1168.44,325279,48.888888888889],[1415145600000,1168.4,1169.92,1137.85,1140.82,389629,42.321428571429],[1415232000000,1140.58,1149.77,1138.14,1141.86,367896,49.909090909091],[1415318400000,1141.95,1178.91,1131.7,1177.48,393023,46.388888888889],[1415577600000,1176.8,1178.16,1147.4,1151.75,375212,46.25],[1415664000000,1151.12,1173.37,1146.2,1164.35,374459,52.5],[1415750400000,1164.27,1170.26,1157.37,1162.66,348626,43.333333333333],[1415836800000,1162.64,1168.13,1154.07,1162.44,361533,49.375],[1415923200000,1162.51,1193.72,1146.9,1188.7,374942,53.333333333333],[1416182400000,1186.86,1194.45,1181.65,1186.62,387037,49.52380952381],[1416268800000,1186.63,1204.8,1183.49,1196.83,344535,47.777777777778],[1416355200000,1197.06,1202.39,1175.26,1182.97,381536,47.5],[1416441600000,1182.69,1197.23,1176.9,1193.79,362438,57.5],[1416528000000,1193.78,1207.96,1186.91,1201.42,370021,50.984848484848],[1416787200000,1201.2,1204.48,1192.84,1197.04,318882,55.980392156863],[1416873600000,1197.05,1203.08,1190.56,1201.11,324231,52.875],[1416960000000,1200.94,1201.95,1194.93,1197.99,281302,0],[1417046400000,1197.85,1199.79,1185.76,1188.8,243352,49.583333333333],[1417132800000,1188.8,1191.8,1165.32,1167.43,240903,49.222222222222],[1417392000000,1167.52,1221.55,1142.86,1212.2,435415,48.666666666667],[1417478400000,1212.06,1213.6,1192.02,1198.17,349570,55.294117647059],[1417564800000,1198.49,1215.31,1194.65,1209.63,259000,52.222222222222],[1417651200000,1209.54,1213.55,1201.41,1204.97,282343,53.333333333333],[1417737600000,1205.38,1207.6,1186.4,1192.42,303352,52.285714285714],[1417996800000,1190.8,1209.05,1187.22,1203.49,288199,49.583333333333],[1418083200000,1203.45,1238.45,1199.32,1231.24,338135,49.242424242424],[1418169600000,1231.1,1238.41,1224.72,1226.3,394925,50.166666666667],[1418256000000,1226.39,1232.92,1215.98,1227.93,402945,44.63199023199],[1418342400000,1227.6,1228.32,1214.53,1222.66,304252,49.845665445665],[1418601600000,1222.5,1224.4,1190.8,1193.3,342741,50.866666666667],[1418688000000,1193.15,1223.61,1187.51,1197.36,376536,48.393424036281],[1418774400000,1196.97,1203.07,1183.81,1189.78,322425,44.769936204147],[1418860800000,1189.43,1213.95,1188.48,1198.43,350832,45.315789473684],[1418947200000,1198.78,1201.46,1193.78,1196.1,313084,46.216666666667],[1419206400000,1195.9,1203.46,1170.78,1176.48,287254,48.287037037037],[1419292800000,1176.42,1185.06,1172.68,1176.41,290849,44.665050635639],[1419379200000,1176.55,1181.36,1172.95,1175.14,189419,45.197278911565],[1419465600000,1177.53,1179.15,1175.14,1177.06,3271,44.166666666667],[1419552000000,1177.53,1199.29,1175.14,1196.01,247428,44.961451247166],[1419811200000,1195.4,1197.6,1178.83,1183.38,279540,50.714285714286],[1419897600000,1183.31,1210.75,1180.84,1200.49,334784,53.805555555556],[1419984000000,1200.4,1203.98,1179.65,1184.36,261652,48.863636363636],[1420070400000,1182.51,1187.33,1182.51,1187.16,3851,45],[1420156800000,1182.51,1195.09,1167.77,1188.64,338965,45.891156462585],[1420416000000,1188.4,1208.05,1178.18,1204.71,327831,47.142113095238],[1420502400000,1204.73,1223.55,1201.76,1218.61,326564,50.733333333333],[1420588800000,1219.05,1219.5,1209.07,1211.27,326107,46.327450980392],[1420675200000,1211.4,1216.73,1204.77,1208.82,317226,48.53835978836],[1420761600000,1208.9,1224.12,1207.4,1222.84,309252,46.985171261487],[1421020800000,1222.9,1236.06,1217.75,1233.95,304501,47.750139772508],[1421107200000,1233.45,1244.26,1227.34,1230.76,373607,51.241228070175],[1421193600000,1230.7,1244.32,1225.14,1228.84,305964,45.746713603856],[1421280000000,1228.69,1266.91,1226.09,1262.93,345536,51.294444444444],[1421366400000,1262.67,1282.21,1255.21,1280.08,307091,43.382563616939],[1421625600000,1279.74,1281.84,1272.23,1276.85,225677,50.452380952381],[1421712000000,1276.85,1297.2,1274.06,1294.94,346395,49.788048552754],[1421798400000,1295.25,1305.22,1284.78,1293.18,348697,52.541730278572],[1421884800000,1293.25,1307.62,1279.61,1302.07,147274,52.815446630664],[1421971200000,1302.4,1302.9,1284.49,1294.27,360807,52.749053030303],[1422230400000,1294.6,1299.34,1275.97,1281.58,369820,46.125],[1422316800000,1281.45,1297.69,1272.36,1292.42,353673,49.061762311762],[1422403200000,1292.32,1293.92,1279.92,1284.76,294037,48.582896635528],[1422489600000,1284.57,1286.02,1252.06,1257.43,368667,46.535036667956],[1422576000000,1257.1,1284.91,1257.1,1283.56,321495,47.585676691729],[1422835200000,1283.4,1283.52,1266.56,1274.17,274827,49.7],[1422921600000,1274.34,1285.94,1255.52,1260.44,334721,52.449275362319],[1423008000000,1260.45,1272.52,1256.79,1269.58,307517,50.217897076186],[1423094400000,1269.25,1274.22,1256.37,1264.91,305433,53.207142857143],[1423180800000,1264.75,1268.92,1228.44,1233.83,274344,44.057142857143],[1423440000000,1233.09,1243.83,1233.09,1239.33,305651,46.996827246827],[1423526400000,1239.15,1246.05,1231.08,1233.53,331421,45.967268270945],[1423612800000,1233.55,1238.94,1216.81,1218.89,278571,44.043650793651],[1423699200000,1218.75,1233.05,1216.95,1221.95,313469,52.657702020202],[1423785600000,1221.95,1235.15,1221.82,1229.53,315901,50.885154061625],[1424044800000,1229.9,1236.84,1227.71,1231.03,192019,48.818027210884],[1424131200000,1230.97,1234.17,1203.85,1209.65,311354,49.283804430863],[1424217600000,1209.65,1213.65,1197.7,1212.73,284911,45.696115288221],[1424304000000,1212.36,1223.19,1205.48,1206.94,300516,44.98778998779],[1424390400000,1206.74,1215.46,1198.33,1202.23,309568,46.350877192982],[1424649600000,1201.86,1210.45,1190.87,1201.69,269838,44.940476190476],[1424736000000,1201.85,1204.68,1190.59,1200.51,303070,45.784958427816],[1424822400000,1200.52,1212.04,1200.19,1204.81,305018,46.784992784993],[1424908800000,1205.07,1220.16,1203.69,1209.55,328108,48.338498463902],[1424995200000,1209.53,1219.45,1204.51,1213.18,281753,47.370367479742],[1425254400000,1213.3,1223.42,1204.65,1207.17,308790,52.583055833056],[1425340800000,1207.11,1214.72,1195.59,1203.77,293646,53.565322025419],[1425427200000,1203.65,1209.15,1198.36,1200.38,297073,51.819805194805],[1425513600000,1200.25,1209.58,1196.57,1198.48,306491,50.039296557255],[1425600000000,1198.35,1200.83,1163.81,1167.88,281767,44.3041220668],[1425859200000,1167.12,1175.51,1165.94,1167.03,263005,42.078334364049],[1425945600000,1167.18,1170.64,1155.39,1161.87,296665,44.454545454545],[1426032000000,1161.84,1165.36,1147.57,1155.14,263700,45.638321995465],[1426118400000,1155.29,1166.67,1148.76,1153.57,317361,48.485513193385],[1426204800000,1153.65,1161.93,1151.49,1157.78,291672,45.796296296296],[1426464000000,1156.9,1164.35,1150.48,1154.74,266396,44.728758169935],[1426550400000,1154.85,1159.89,1142.82,1149.52,291855,44.266917293233],[1426636800000,1149.65,1175.61,1146,1167.68,298428,42.612918827205],[1426723200000,1167.2,1178.01,1159.77,1170.97,341546,46.751065090653],[1426809600000,1170.9,1188.06,1168.82,1182.59,273396,46.022927689594],[1427068800000,1183.47,1191.82,1179.35,1189.51,317525,49.976339020457],[1427155200000,1189.69,1195.17,1185.46,1193.24,303380,47.349282296651],[1427241600000,1193.26,1199.92,1186.72,1195.38,290404,44.966183574879],[1427328000000,1195.36,1219.83,1194.45,1204.81,328284,50.17094017094],[1427414400000,1204.87,1206.35,1192.65,1198.78,299738,47.906629318394],[1427673600000,1198.26,1199.71,1182.53,1186.22,280333,47.295673825086],[1427760000000,1186.12,1190.86,1178.55,1183.69,314713,43.43501984127],[1427846400000,1183.72,1208.69,1180.94,1204.04,279403,50.788220551378],[1427932800000,1204.15,1207.51,1195.05,1202.9,292059,47.206349206349],[1428278400000,1202.99,1224.46,1202.99,1214.95,277305,44.612713675214],[1428364800000,1215.04,1216.01,1207.61,1209.17,271744,47.031547619048],[1428451200000,1209.22,1212.49,1197.56,1202.61,277326,43.283213206231],[1428537600000,1202.55,1203.51,1192.73,1194.78,272554,46.626914751915],[1428624000000,1194.78,1210.85,1193.38,1207.38,292818,47.672412554765],[1428883200000,1207.91,1209.64,1196.44,1198.93,274542,46.843434343434],[1428969600000,1198.85,1201.73,1184.07,1192.85,309698,45.860618321403],[1429056000000,1192.81,1204.78,1189.02,1202.56,201462,46.619288119288],[1429142400000,1202.62,1209.29,1194.81,1198.61,356385,46.898148148148],[1429228800000,1198.56,1207.87,1197.49,1204.22,294333,60],[1429488000000,1204.2,1209.28,1191.47,1195.81,281241,49.363636363636],[1429574400000,1195.91,1204.38,1193.23,1202.44,272277,51.25],[1429660800000,1202.81,1204.96,1185.82,1187.07,295977,60],[1429747200000,1187.21,1198.2,1184.42,1193.96,326288,50],[1429833600000,1194.09,1196.13,1175.25,1179.52,303031,40],[1430092800000,1179.16,1207.36,1178.66,1202.19,323344,0],[1430179200000,1202.12,1215.25,1199.28,1212.52,304200,47.5],[1430265600000,1212.57,1214.17,1201.53,1204.91,322585,50],[1430352000000,1204.85,1207.38,1176.95,1184.42,348064,60],[1430438400000,1184.35,1185.37,1170.44,1178.44,265441,50],[1430697600000,1178.4,1193.05,1177.61,1188.41,297263,60],[1430784000000,1188.37,1199.88,1185.82,1193.15,305214,60],[1430870400000,1193.25,1197.83,1188.38,1192.28,305603,60],[1430956800000,1192.05,1193.04,1179,1184.55,308580,40],[1431043200000,1184.48,1193.93,1181.86,1188.49,299843,40],[1431302400000,1188.66,1191.94,1179.06,1183.94,272438,52.5],[1431388800000,1183.95,1197.22,1180.95,1194.1,287283,60],[1431475200000,1194.12,1219.06,1191.29,1215.76,284407,60],[1431561600000,1215.65,1227.29,1212.35,1221.19,316944,40],[1431648000000,1221.19,1226.43,1211.1,1224.1,278829,40],[1431907200000,1224.49,1232.47,1221.57,1225.43,290557,0],[1431993600000,1225.47,1225.91,1205.91,1207.8,327756,56.666666666667],[1432080000000,1207.81,1213.71,1203.34,1209.86,311390,0],[1432166400000,1209.87,1212.93,1201.75,1206.34,275075,40],[1432252800000,1206.25,1214.99,1201.62,1206.24,250281,60],[1432512000000,1205.77,1209.2,1202.9,1206.82,152362,43.333333333333],[1432598400000,1207.32,1207.71,1185.65,1187.04,304447,45.464803312629],[1432684800000,1187.35,1191.04,1183.81,1187.96,311210,46.633408919123],[1432771200000,1187.95,1192.31,1180.47,1188.05,299090,45.019270584488],[1432857600000,1188.4,1193.56,1185.82,1190.26,306011,47.175757575758],[1433116800000,1190.7,1204.47,1184.61,1189.28,309601,50.785714285714],[1433203200000,1189.24,1196.27,1185.95,1192.93,319646,46.206766917293],[1433289600000,1193.15,1195.6,1179.66,1185.04,296888,47.75666000666],[1433376000000,1185.05,1186.41,1172.82,1176.86,337291,43.895833333333]];
var chart_option = {
            rangeSelector: {
                selected: 1
            },
            title: {
                text: 'Price'
            },
            yAxis: [{
                labels: {
                    align: 'left',
                    x: 3
                },
                title: {
                    text: 'Price'
                },
                height: '75%',
                lineWidth: 2,
                opposite: false
            }, {
                labels: {
                    align: 'left',
                    x: 3
                },
                title: {
                    text: 'Sentiment'
                },
                height: '75%',
                offset: 0,
                lineWidth: 2,
                opposite: true
            }, {
                labels: {
                    align: 'left',
                    x: 3
                },
                title: {
                    text: 'Volume'
                },
                top: '80%',
                height: '20%',
                offset: 0,
                lineWidth: 2,
                opposite: false
            }],
            tooltip: {
                enabledIndicators: true
            },
            credits: {
                enabled: false
            }
        };
       // split the data set into ohlc and volume
        var ohlc = [],
        volume = [],
        sentiment = [],
        dataLength = data.length,
        i = 0,
        groupingUnits = [[
              'week',                         // unit name
              [1]                             // allowed multiples
          ], [
              'month',
              [1, 2, 3, 4, 6]
          ]];

        // Add a null value for the end date
        //data = [].concat(data, [[Date.UTC(2015, 1, 30, 21, 0), null, null, null, null]]);
        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
            ]);

            sentiment.push([
                data[i][0], // the date
                data[i][6] // value
            ]);

            volume.push([
                data[i][0], // the date
                data[i][5] // the volume
            ]);
        }
        chart_option['series'] = [{
            id: 'Price',
            type: 'candlestick',
            name: 'Price',
            data: ohlc,
            dataGrouping: {
                enabled: false
            }
        }, {
            id: 'Sentiment',
            type: 'spline',
            name: 'Sentiment',
            data: sentiment,
            yAxis: 1,
            dataGrouping: {
                enabled: false
            }
        }, {
            type: 'column',
            name: 'Volume',
            data: volume,
            yAxis: 2,
            dataGrouping: {
                enabled: false
            }
        }];

        // create the chart
        $('#charts').highcharts('StockChart', chart_option);
});
</script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.