@@ -6,73 +6,76 @@ async function getIndicatorData(inficatorCode, tickerId, timeframe = '1w', perio
66 return { result, plots, marketData } ;
77}
88console . log ( 'Getting indicator data...' ) ;
9- const promises = [
10- getIndicatorData ( sqzmomIndicator , 'BTCUSDT' , 'W' , DATA_LENGTH ) ,
11- getIndicatorData ( macdIndicator , 'BTCUSDT' , 'W' , DATA_LENGTH ) ,
12- getIndicatorData ( institBiasIndicator , 'BTCUSDT' , 'W' , DATA_LENGTH ) ,
13- ] ;
14- const results = await Promise . all ( promises ) ;
15- const { marketData, plots : sqzmomPlots } = results [ 0 ] ;
16- const { plots : institBiasPlots } = results [ 2 ] ;
17- const { plots : macdPlots } = results [ 1 ] ;
189
19- // Map Market Data to QFChart OHLCV format
20- // marketData is array of objects: { openTime, open, high, low, close, volume }
21- const ohlcvData = marketData . map ( ( k ) => ( {
22- time : k . openTime ,
23- open : k . open ,
24- high : k . high ,
25- low : k . low ,
26- close : k . close ,
27- volume : k . volume ,
28- } ) ) ;
10+ ( async ( ) => {
11+ const promises = [
12+ getIndicatorData ( sqzmomIndicator , 'BTCUSDT' , 'W' , DATA_LENGTH ) ,
13+ getIndicatorData ( macdIndicator , 'BTCUSDT' , 'W' , DATA_LENGTH ) ,
14+ getIndicatorData ( institBiasIndicator , 'BTCUSDT' , 'W' , DATA_LENGTH ) ,
15+ ] ;
16+ const results = await Promise . all ( promises ) ;
17+ const { marketData , plots : sqzmomPlots } = results [ 0 ] ;
18+ const { plots : institBiasPlots } = results [ 2 ] ;
19+ const { plots : macdPlots } = results [ 1 ] ;
2920
30- // Initialize Chart
31- const chartContainer = document . getElementById ( 'main-chart' ) ;
32- window . chart = new QFChart . QFChart ( chartContainer , {
33- title : 'BTC/USDT' , // Custom title
34- height : '840px' ,
35- padding : 0.2 ,
36- databox : {
37- position : 'floating' ,
38- } ,
39- dataZoom : {
40- visible : true ,
41- position : 'top' ,
42- height : 6 ,
43- start : 50 ,
44- end : 100 ,
21+ // Map Market Data to QFChart OHLCV format
22+ // marketData is array of objects: { openTime, open, high, low, close, volume }
23+ const ohlcvData = marketData . map ( ( k ) => ( {
24+ time : k . openTime ,
25+ open : k . open ,
26+ high : k . high ,
27+ low : k . low ,
28+ close : k . close ,
29+ volume : k . volume ,
30+ } ) ) ;
4531
46- zoomLock : false ,
47- moveOnMouseMove : true ,
48- // This prevents the grab cursor
49- preventDefaultMouseMove : false ,
50- } ,
51- layout : {
52- mainPaneHeight : '60%' ,
53- gap : 5 ,
54- } ,
55- } ) ;
32+ // Initialize Chart
33+ const chartContainer = document . getElementById ( 'main-chart' ) ;
34+ window . chart = new QFChart . QFChart ( chartContainer , {
35+ title : 'BTC/USDT' , // Custom title
36+ height : '840px' ,
37+ padding : 0.2 ,
38+ databox : {
39+ position : 'floating' ,
40+ } ,
41+ dataZoom : {
42+ visible : true ,
43+ position : 'top' ,
44+ height : 6 ,
45+ start : 50 ,
46+ end : 100 ,
5647
57- // Set Market Data
58- chart . setMarketData ( ohlcvData ) ;
48+ zoomLock : false ,
49+ moveOnMouseMove : true ,
50+ // This prevents the grab cursor
51+ preventDefaultMouseMove : false ,
52+ } ,
53+ layout : {
54+ mainPaneHeight : '60%' ,
55+ gap : 5 ,
56+ } ,
57+ } ) ;
5958
60- chart . addIndicator ( 'Institutional Bias' , institBiasPlots , {
61- isOverlay : true ,
62- titleColor : '#2962FF' ,
63- } ) ;
59+ // Set Market Data
60+ chart . setMarketData ( ohlcvData ) ;
6461
65- // Set Indicators
66- // Group plots into one indicator
67- chart . addIndicator ( 'MACD' , macdPlots , {
68- isOverlay : false ,
69- height : 16 ,
70- titleColor : '#ff9900' ,
71- controls : { collapse : true , maximize : true } ,
72- } ) ;
62+ chart . addIndicator ( 'Institutional Bias' , institBiasPlots , {
63+ isOverlay : true ,
64+ titleColor : '#2962FF' ,
65+ } ) ;
7366
74- chart . addIndicator ( 'SQZMOM' , sqzmomPlots , {
75- isOverlay : false ,
76- height : 16 ,
77- controls : { collapse : true , maximize : true } ,
78- } ) ;
67+ // Set Indicators
68+ // Group plots into one indicator
69+ chart . addIndicator ( 'MACD' , macdPlots , {
70+ isOverlay : false ,
71+ height : 16 ,
72+ titleColor : '#ff9900' ,
73+ controls : { collapse : true , maximize : true } ,
74+ } ) ;
75+
76+ chart . addIndicator ( 'SQZMOM' , sqzmomPlots , {
77+ isOverlay : false ,
78+ height : 16 ,
79+ controls : { collapse : true , maximize : true } ,
80+ } ) ;
81+ } ) ( ) ;
0 commit comments