Skip to content

Instantly share code, notes, and snippets.

@parthi2929
Created December 9, 2017 02:23
Show Gist options
  • Save parthi2929/7ea80d1a7243cd8b4d256adb59fb9d7b to your computer and use it in GitHub Desktop.
Save parthi2929/7ea80d1a7243cd8b4d256adb59fb9d7b to your computer and use it in GitHub Desktop.
Highcharts candle stick demo with rsi indicator - data source is a dummy google sheets OHLC random (but structured) data
<!DOCTYPE html><html>
<head>
<title>Test</title>
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type='text/javascript' src="http://code.highcharts.com/stock/highstock.js"></script>
<script type='text/javascript' src="http://code.highcharts.com/stock/modules/data.js"></script>
<script src="https://code.highcharts.com/stock/indicators/indicators.js"></script>
<script src="https://code.highcharts.com/stock/indicators/rsi.js"></script>
<script type='text/javascript'> </script>
<script type='text/javascript'> $(window).load(function()
{
var chart = new Highcharts.StockChart(
{
chart:
{
renderTo: "container",
type: 'candlestick'
},
legend:
{
enabled: true
},
tooltip:
{
shared: true
},
yAxis:
[
{
height: 200,
title:
{
text:'Candle'
}
},
{
top: 300,
height: 100,
offset: 0,
lineWidth: 2,
title:
{
text:'RSI'
}
}
],
plotOptions:
{
series:
{
turboThreshold: 0
},
candlestick:
{
color: 'red',
upColor: 'green'
}
},
data:
{
googleSpreadsheetKey: '1HCVyjz7H45-CGeKXPZZ8RQRIq2CC5_JEYAp0WwahVHE',
seriesMapping:
[
{
open: 1,
high: 2,
low: 3,
close: 4
}
],
parseDate: function(d)
{
var month = parseInt(d.substring(0,2)) - 1,
day = parseInt(d.substring(3,5)),
year = parseInt("20" + d.substring(8,10)),
hours = parseInt(d.substring(11,d.indexOf(':'))),
minutes = parseInt(d.substring(d.indexOf(':')+1)),
date = Date.UTC(year, month, day, hours, minutes);
return date;
}
},
series:
[
{
id: 'one'
}
]
}, function(chart)
{
chart.addSeries(
{
name: 'rsi',
linkedTo: 'one',
showInLegend: true,
yAxis: 1,
type: 'rsi'
});
});
});
</script>
</head>
<body>
<div id="container" style="min-width: 500x; height: 500px; margin: 0 auto"></div>
</body>
</html>
@slidenerd
Copy link

slidenerd commented Feb 6, 2018

Far better if you use D3 instead, if you have seen the licensing terms for highcharts, they dont allow commercial use, its not like the common software wizard s gonna buy an 850$ license for this, highcharts, fusioncharts, amcharts = strict NO NO, go for d3 or if you prefer out of box solutions use d3 + techan, i personally like building my own so its pure d3 for me, github techan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment