@@ -4,21 +4,29 @@ const TradingView = require('../main');
44 * This example creates a chart with all user's private indicators
55 */
66
7- if ( ! process . argv [ 2 ] ) throw Error ( 'Please specify your \'sessionid\' cookie' ) ;
8- if ( ! process . argv [ 3 ] ) throw Error ( 'Please specify your \'signature\' cookie' ) ;
7+ if ( ! process . env . SESSION || ! process . env . SIGNATURE ) {
8+ throw Error ( 'Please set your sessionid and signature cookies' ) ;
9+ }
910
1011const client = new TradingView . Client ( {
11- token : process . argv [ 2 ] ,
12- signature : process . argv [ 3 ] ,
12+ token : process . env . SESSION ,
13+ signature : process . env . SIGNATURE ,
1314} ) ;
1415
1516const chart = new client . Session . Chart ( ) ;
1617chart . setMarket ( 'BINANCE:BTCEUR' , {
1718 timeframe : 'D' ,
1819} ) ;
1920
20- TradingView . getPrivateIndicators ( process . argv [ 2 ] ) . then ( ( indicList ) => {
21- indicList . forEach ( async ( indic ) => {
21+ ( async ( ) => {
22+ const indicList = await TradingView . getPrivateIndicators ( process . argv [ 2 ] ) ;
23+
24+ if ( ! indicList . length ) {
25+ console . error ( 'Your account has no private indicators' ) ;
26+ process . exit ( 0 ) ;
27+ }
28+
29+ for ( const indic of indicList ) {
2230 const privateIndic = await indic . get ( ) ;
2331 console . log ( 'Loading indicator' , indic . name , '...' ) ;
2432
@@ -32,5 +40,5 @@ TradingView.getPrivateIndicators(process.argv[2]).then((indicList) => {
3240 console . log ( 'Plot values' , indicator . periods ) ;
3341 console . log ( 'Strategy report' , indicator . strategyReport ) ;
3442 } ) ;
35- } ) ;
36- } ) ;
43+ }
44+ } ) ( ) ;
0 commit comments