Mathieu2301 / TradingView-API

📈 Get real-time stocks from TradingView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't setOption iside a Promise for multiple indicators

doohab opened this issue · comments

Hi Mathieu2301,

I am sure this is very simple some how but I can't get grip of it.
In the example file (MultipleSyncFetch.js), I am trying to set some option to each indicator individually:

function getIndicData(indicator) {

/* not setting options */
if (indicator == "STD;Supertrend") 
{ indicator.setOption('ATR_Length', 1) }

  return new Promise((res) => {

/* not setting options */
if (indicator == "STD;Supertrend") 
{ indicator.setOption('ATR_Length', 1) }

    const STD = new chart.Study(indicator);

    console.log(`Getting "${indicator.description}"...`);

    STD.onUpdate(() => {
      res(STD.periods);
      console.log(`"${indicator.description}" done !`);
    });
  });
}

I tried to follow instructions mentioned in #61, but it doesn't seems to work for me.