79 indicators
Search them by name, browse by category and star your favorites. Add the same moving average as many times as you like.
The chart that runs the simul8or trading simulators, free for your site. Candles, 79 indicators, drawing tools and live data in one library with zero dependencies.
79 indicators in a searchable picker, on top of v4.0's full drawing toolbar.
Search them by name, browse by category and star your favorites. Add the same moving average as many times as you like.
See where the volume traded for the bars on screen or for each session, with the point of control and value area marked.
Every indicator gets its own legend line. Hover it to hide the line, change its inputs and colors, or take it off the chart.
Trend stops, channels, pivots, Williams Alligator and Fractals, Zig Zag and 20+ new oscillators like TSI, Vortex and Klinger.
Both charts below are streaming real prices right now, from the same few lines of code shown further down.
Open, high, low and close at a glance, with volume and MACD panes and the full toolbar.
A clean closing-price view in the built-in light theme, with a moving average on top.
Everything you need for stunning financial visualizations.
Candlestick, line charts, and more with a single click.
Intuitive drag to pan, scroll to zoom, and touch controls.
Automatically adapts to any screen size or device.
Built-in theme switching with a single click.
Optimized canvas rendering for large datasets.
Expand your charts to fullscreen with a single click.
<link rel="stylesheet" href="stock-chart.css"> <script src="indicators.js" defer></script> <script src="patterns.js" defer></script> <script src="emoji-data.js" defer></script> <script src="stockchart.js" defer></script>
<div id="chart-container" style="width: 100%; height: 400px;"></div>
// Sample OHLC data
const data = [
{ t: 1675209600000, open: 180.68, high: 187.12,
low: 179.26, close: 185.38, volume: 4235600 },
// ... more data points
];
// Initialize chart
const chart = new StockChart('chart-container', {
data: data,
ticker: 'AAPL',
darkMode: true
});
The demos on this page use Hyperliquid's free public crypto API. No key or account needed. Load recent candles, then keep the last one updating:
const API = 'https://api.hyperliquid.xyz';
const toBar = c => ({ t: c.t, open: +c.o, high: +c.h, low: +c.l, close: +c.c, volume: +c.v });
// 1. Last 300 one-minute BTC candles
const res = await fetch(API + '/info', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ type: 'candleSnapshot', req: {
coin: 'BTC', interval: '1m', startTime: Date.now() - 300 * 60000, endTime: Date.now() } })
});
const chart = new StockChart('chart-container', {
data: (await res.json()).map(toBar),
ticker: 'BTC', timeframe: '1min', chartType: 'candlestick', darkMode: true
});
// 2. Live updates over a WebSocket
const ws = new WebSocket('wss://api.hyperliquid.xyz/ws');
ws.onopen = () => ws.send(JSON.stringify({ method: 'subscribe',
subscription: { type: 'candle', coin: 'BTC', interval: '1m' } }));
ws.onmessage = e => {
const msg = JSON.parse(e.data);
if (msg.channel !== 'candle') return;
const bar = toBar(msg.data), data = chart.stockData, last = data[data.length - 1];
if (last && last.t === bar.t) Object.assign(last, bar);
else {
data.push(bar);
if (chart.isViewPinnedToRightEdge) // keep the newest candle in view
chart.config.dataOffset = Math.max(0, data.length - chart.config.visibleCandles);
}
chart.calculateIndicators();
chart.drawCharts();
};
The chart library expects an array of objects with the following structure:
[
{
t: 1675209600000, // Timestamp in milliseconds
open: 180.68, // Opening price
high: 187.12, // Highest price
low: 179.26, // Lowest price
close: 185.38, // Closing price
volume: 4235600 // Volume
},
// More data points...
]
Important: Data should be sorted chronologically with the oldest data points first.
Customize your charts to fit your needs:
| Option | Type | Default | Description |
|---|---|---|---|
data | Array | — | Array of OHLC data objects (required) |
ticker | String | 'NVDA' | Stock symbol to display |
chartType | String | 'line' | 'line' or 'candlestick' |
darkMode | Boolean | false | Enable dark mode |
timeframe | String | auto | '1min', '5min', '15min', '1hour', '1day' and more; detected from the data if left out |
indicators | Object | — | Indicators to start with, e.g. { volume: true, supertrend: true, rsi: true }. Keys for the newer ones are in StockChart.STUDIES |
tickerLogoUrl | Function | — | Optional. symbol => url for a logo next to the ticker |
chart.drawCharts()Redraw chartchart.resizeCanvases()Resize canvaseschart.updateConfig(newConfig)Update optionschart.setIndicatorEnabled('vrvp', true)Turn an indicator on or offchart.addMovingAverageInstance('ema', 50, '#f5b14a')Add a moving averagechart.destroy()Clean upGet started with our chart library today.