Mathieu2301 / TradingView-API

📈 Get real-time stocks from TradingView
1.47k stars 332 forks source link

check study unexpected error #240

Open TimUnderhay opened 5 months ago

TimUnderhay commented 5 months ago

Describe the bug When attempting to study a builtin indicator (DEMA), the client errors with check study unexpected error. I'm sure the issue is something I've done wrong, but I've attempted to follow the examples and read the jsDocs, but the error isn't enough to go on.

To Reproduce

const client = new TradingView.Client({
  token: 'sometoken',
  signature: 'somesignature'
});
const chart = new client.Session.Chart();
chart.setMarket(
  'BINANCE:BTCUSDT',
  {
    timeframe: '5',
    range: 100
  }
);
const demaProfile = new TradingView.BuiltInIndicator('STD;DEMA');

// I've tried with and without these options:
demaProfile.setOption('pineFeatures', '{"indicator":1,"plot":1,"ta":1}');
demaProfile.setOption('in_0', 63); // length
demaProfile.setOption('in_1', 'close'); // source
demaProfile.setOption('in_2', ''); // timeframe
demaProfile.setOption('in_3', true); // Wait for timeframe closes
demaProfile.setOption('__profile', false);

const study = new chart.Study(demaProfile)
study.onUpdate(
  () => {
    console.log(
      util.inspect(study.graphic, { showHidden: true, depth: Infinity, colors: true, showProxy: true })
    )
    client.end();
  }
);
// prints "check study unexpected error"

Expected behavior Expect no error

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

Additional context Add any other context about the problem here.