TradingView-API icon indicating copy to clipboard operation
TradingView-API copied to clipboard

Renko chart's indicator value does not match GUI-based TradingView's, given same configurations

Open VRspace4 opened this issue 4 years ago • 8 comments

Both the code and the GUI-based TradingView chart have the exact same configurations - chart type, timeframe, regular session, box size, etc. Both also have the exact same indicator, CM_Ultimate_MA_MTF_V2. The issue is that the study.periods[0].MultiTimeframe_Moving_Avg indicator value output should be the same as the GUI-based TradingView chart, but unfortunately they are not the same.

const TradingView = require('../main');

const privateSessionId = process.env.TRADINGVIEW_SESSIONID;

const client = new TradingView.Client({
  token: privateSessionId,
});

const chart = new client.Session.Chart();
chart.setMarket('NASDAQ:AAPL', {
  session: 'regular',
  type: 'Renko',
  timeframe: '1',
  inputs: {
    source: 'close',
    sources: 'Close',
    boxSize: 3,
    style: 'Traditional',
    atrLength: 14,
    wicks: true,
  },
});

const publicFmp = TradingView.searchIndicator('CM_Ultimate_MA_MTF_V2').then(async (indicator) => {
  indicator[0].source = '-',
  console.log(
    '*** Indicator information \n',
    indicator[0],
  );
  const pineIndicator = await indicator[0].get();
  const study = new chart.Study(pineIndicator);
  study.onUpdate(() => {
    console.log(
      `\n*** Chart time and close:\n`,
      chart.periods[0].time,
      chart.periods[0].close
    );
    console.log(
      '\n*** Indicator value:\n',
      study.periods[0].MultiTimeframe_Moving_Avg,
    );
  })
})

TradingView-API Output

image

GUI-based TradingView Chart

image

VRspace4 avatar Nov 21 '21 23:11 VRspace4

Hello, It's working for me when you remove inputs property in setMarket:

...
chart.setMarket('NASDAQ:AAPL', {
  type: 'Renko',
  timeframe: '1', // 1 minute
});
...

Mathieu2301 avatar Nov 24 '21 14:11 Mathieu2301

I tried with the Traditional style and I have the same problem as you.

Mathieu2301 avatar Nov 24 '21 14:11 Mathieu2301

I can't seem to find any patterns. There are some box size values that match perfectly and some that do not. I've compared the WS output from the Developer Networking tab and have confirmed that they do agree with the code - for example:

2: "={\"symbol\":{\"symbol\":\"NASDAQ:AAPL\",\"currency-id\":\"USD\",\"adjustment\":\"splits\",\"session\":\"regular\"},\"type\":\"BarSetRenko@tv-prostudies-40!\",\"inputs\":{\"source\":\"close\",\"sources\":\"Close\",\"boxSize\":3,\"style\":\"Traditional\",\"atrLength\":14,\"wicks\":true}}"

Any new developments on your end?

VRspace4 avatar Nov 25 '21 01:11 VRspace4

First, thank you for your work! I've got the same problem here with another private indicator. Setting a different option instead the default returns wrong values. Do you already got an idea how to solve this?

FuturesTr4der avatar Dec 27 '21 00:12 FuturesTr4der

Hello, I didn't found any solution to this, and my TW Pro trial has expired. (I don't have the problem with higher timeframes...) I think that the only thing to do is to compare all sent WebSocket requests (browser vs API) and see where is the difference.

Mathieu2301 avatar Dec 27 '21 00:12 Mathieu2301

@VRspace4 did you solve it ?

Mathieu2301 avatar Dec 27 '21 00:12 Mathieu2301

I think that the only thing to do is to compare all sent WebSocket requests (browser vs API) and see where is the difference.

It could be a difference of just one char ! The comparaison must be perfect !

Mathieu2301 avatar Dec 27 '21 00:12 Mathieu2301

Thanks, i will analyse it

FuturesTr4der avatar Dec 27 '21 01:12 FuturesTr4der