Mathieu2301 / TradingView-API

📈 Get real-time stocks from TradingView
1.61k stars 354 forks source link

why i cant get my private indicators? #153

Open ikulichkov opened 2 years ago

ikulichkov commented 2 years ago

check please my code what i missed?

import TradingView from '@mathieuc/tradingview'

TradingView.loginUser(process.argv[2], process.argv[3], false).then((user) => {
  console.log('User:', user);
  console.log('Sessionid:', user.session);
// if (!process.argv[2]) throw Error('Please specify your \'sessionid\' cookie');

const client = new TradingView.Client({
  token: process.argv[2],
});

const chart = new client.Session.Chart();
chart.setMarket('BINANCE:BTCUSDTPERP', {
  timeframe: 'D',
});

TradingView.getPrivateIndicators(process.argv[2]).then((indicList) => {
  indicList.forEach(async (indic) => {
    const privateIndic = await indic.get();
    console.log('Loading indicator', indic.name, '...');

    const indicator = new chart.Study(privateIndic);

    indicator.onReady(() => {
      console.log('Indicator', indic.name, 'loaded !');
    });

    indicator.onUpdate(() => {
      console.log('Plot values', indicator.periods);
      console.log('Strategy report', indicator.strategyReport);
    });
  });
});
}).catch((err) => {
  console.error('Login error:', err.message);
});

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object

lumpov commented 1 year ago

check your process.argv[*]