Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Generate TradingView-style dark-theme candlestick charts with RSI, MACD, Bollinger Bands, and EMA/SMA using mplfinance.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
templates/candlestick.html
1<!DOCTYPE html>2<html lang="en">3<head>4<meta charset="UTF-8">5<meta name="viewport" content="width=device-width, initial-scale=1.0">6<title>Candlestick Chart</title>7<script src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>8<style>{{BASE_STYLES}}</style>9</head>10<body>11<div class="toolbar">12<div>13<h1>{{TITLE}}</h1>14<div class="subtitle">{{SUBTITLE}}</div>15</div>16<div class="actions">17<button onclick="downloadPNG(this)">๐ฅ Download PNG</button>18<button onclick="copyToClipboard(this)">๐ Copy Image</button>19<button onclick="saveToProject(this)">๐พ Save Image</button>20</div>21</div>2223<div id="chart-area">24<div id="kline-chart" style="width:100%;height:500px;"></div>25</div>2627<script>{{BASE_EXPORT_JS}}</script>28<script>29// === DATA: [date, open, close, low, high, volume] ===30const rawData = [31['2025-01-02', 94500, 96200, 93800, 96800, 12500],32['2025-01-03', 96200, 95100, 94200, 97000, 11200],33['2025-01-04', 95100, 97800, 94800, 98200, 15300],34// ... replace with real data35];3637const dates = rawData.map(d => d[0]);38const ohlc = rawData.map(d => [d[1], d[2], d[3], d[4]]); // open, close, low, high39const volumes = rawData.map(d => d[5]);40const isUp = rawData.map(d => d[2] >= d[1]);4142// Simple MA calculation43function calcMA(data, period) {44const result = [];45for (let i = 0; i < data.length; i++) {46if (i < period - 1) { result.push('-'); continue; }47let sum = 0;48for (let j = 0; j < period; j++) sum += data[i - j][1]; // close price49result.push((sum / period).toFixed(2));50}51return result;52}5354window.CHART_INSTANCES = [];55const chart = echarts.init(document.getElementById('kline-chart'), 'dark');56chart.setOption({57backgroundColor: 'transparent',58tooltip: {59trigger: 'axis',60axisPointer: { type: 'cross' },61},62legend: { data: ['K', 'MA7', 'MA25'], top: 8 },63grid: [64{ top: 50, left: 60, right: 30, height: '60%' },65{ left: 60, right: 30, top: '76%', height: '16%' },66],67xAxis: [68{ type: 'category', data: dates, gridIndex: 0, boundaryGap: true,69axisLine: { lineStyle: { color: '#2d3148' } } },70{ type: 'category', data: dates, gridIndex: 1, boundaryGap: true,71axisLine: { lineStyle: { color: '#2d3148' } } },72],73yAxis: [74{ scale: true, gridIndex: 0, splitLine: { lineStyle: { color: '#1e2236' } } },75{ scale: true, gridIndex: 1, splitLine: { show: false },76axisLabel: { show: false }, axisTick: { show: false } },77],78dataZoom: [79{ type: 'inside', xAxisIndex: [0, 1], start: 0, end: 100 },80{ type: 'slider', xAxisIndex: [0, 1], height: 20, bottom: 5 },81],82series: [83{84name: 'K', type: 'candlestick', data: ohlc,85itemStyle: {86color: '#26a69a', color0: '#ef5350',87borderColor: '#26a69a', borderColor0: '#ef5350',88},89},90{ name: 'MA7', type: 'line', data: calcMA(ohlc, 7), smooth: true,91lineStyle: { width: 1.5 }, symbol: 'none' },92{ name: 'MA25', type: 'line', data: calcMA(ohlc, 25), smooth: true,93lineStyle: { width: 1.5 }, symbol: 'none' },94{95name: 'Volume', type: 'bar', xAxisIndex: 1, yAxisIndex: 1,96data: volumes.map((v, i) => ({97value: v,98itemStyle: { color: isUp[i] ? 'rgba(38,166,154,0.5)' : 'rgba(239,83,80,0.5)' },99})),100},101],102});103104CHART_INSTANCES.push(chart);105</script>106</body>107</html>108