@@ -27,7 +27,7 @@ permalink: /
2727 <a href="https://github.com/QuantForgeOrg/PineTS" target="_blank">PineTS</a> library to get the data and the indicators.
2828 </p>
2929 <hr />
30- <div id="main-chart"><center>Loading...</center>< /div>
30+ <div id="main-chart"></div>
3131</div >
3232
3333<!-- QFChart Library (Bundled with ECharts) -->
@@ -38,94 +38,7 @@ permalink: /
3838<script src =" ./js/indicators/sqzmom.js " ></script >
3939<script src =" ./js/indicators/macd.js " ></script >
4040<script src =" ./js/indicators/instit-bias.js " ></script >
41-
42- <script >
43- // Data Loading Helper (Simulating what was in chart.js)
44- const DATA_LENGTH = 500 ;
45- async function getIndicatorData (inficatorCode , tickerId , timeframe = ' 1w' , periods = 500 , stime , etime ) {
46- const pineTS = new PineTS (PineTS .Provider .Binance , tickerId, timeframe, periods, stime, etime);
47- const { result , plots , marketData } = await pineTS .run (inficatorCode);
48- return { result, plots, marketData };
49- }
50-
51- // Initialize QFChart
52- document .addEventListener (' DOMContentLoaded' , async () => {
53- const promises = [
54- getIndicatorData (sqzmomIndicator, ' BTCUSDT' , ' W' , DATA_LENGTH ),
55- getIndicatorData (macdIndicator, ' BTCUSDT' , ' W' , DATA_LENGTH ),
56- getIndicatorData (institBiasIndicator, ' BTCUSDT' , ' W' , DATA_LENGTH ),
57- ];
58- const results = await Promise .all (promises);
59- const { marketData , plots: sqzmomPlots } = results[0 ];
60- const { plots: institBiasPlots } = results[2 ];
61- const { plots: macdPlots } = results[1 ];
62-
63-
64- // Map Market Data to QFChart OHLCV format
65- // marketData is array of objects: { openTime, open, high, low, close, volume }
66- const ohlcvData = marketData .map ((k ) => ({
67- time: k .openTime ,
68- open: k .open ,
69- high: k .high ,
70- low: k .low ,
71- close: k .close ,
72- volume: k .volume ,
73- }));
74-
75-
76- // Initialize Chart
77- const chartContainer = document .getElementById (' main-chart' );
78- window .chart = new QFChart.QFChart (chartContainer, {
79- title: ' BTC/USDT' , // Custom title
80- height: ' 840px' ,
81- padding: 0.2 ,
82- databox: {
83- position: ' floating' ,
84- },
85- dataZoom: {
86- visible: true ,
87- position: ' top' ,
88- height: 6 ,
89- start: 50 ,
90- end: 100 ,
91-
92- zoomLock: false ,
93- moveOnMouseMove: true ,
94- // This prevents the grab cursor
95- preventDefaultMouseMove: false ,
96- },
97- layout: {
98- mainPaneHeight: ' 60%' ,
99- gap: 5 ,
100- },
101- });
102-
103- // Set Market Data
104- chart .setMarketData (ohlcvData);
105-
106- chart .addIndicator (' Institutional Bias' , institBiasPlots, {
107- isOverlay: true ,
108- titleColor: ' #2962FF' ,
109- });
110-
111- // Set Indicators
112- // Group plots into one indicator
113- chart .addIndicator (' MACD' , macdPlots, {
114- isOverlay: false ,
115- height: 16 ,
116- titleColor: ' #ff9900' ,
117- controls: { collapse: true , maximize: true },
118- });
119-
120- chart .addIndicator (' SQZMOM' , sqzmomPlots, {
121- isOverlay: false ,
122- height: 16 ,
123- controls: { collapse: true , maximize: true },
124- });
125-
126-
127- });
128- </script >
41+ <script src =" ./js/chart.js " >
12942
13043## Installation
13144
@@ -135,13 +48,14 @@ Include the bundled script in your HTML file:
13548
13649` ` ` html
13750<script src="dist/qfchart.dev.browser.js"></script>
138- ```
51+
52+ ` ` ` `
13953
14054### NPM (Coming Soon)
14155
14256` ` ` bash
14357npm install qfchart
144- ```
58+ ` ` ` `
14559
14660## Quick Start
14761
0 commit comments