Mathieu2301 / TradingView-API

📈 Get real-time stocks from TradingView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setMarket { range } not impacting how far back data result goes

Joeo1 opened this issue · comments

commented

Hi Mathieu,

Describe the bug
If I set the market to retrieve indicator data like this:

that.chart.setMarket(that.params.market, {
				  
        timeframe: '1D',
        range: 800,
        to: Date.now(),
});

It doesn't matter how high I set the range, it will only return data starting at Sat Jan 01 2022 01:00:00
In my Tradingview charts in my browser I can go back all the way back to around 2020

To Reproduce


that.chart = new client.Session.Chart();

that.chart.setMarket(that.params.market, {
				  
        timeframe: '1D',
        range: 800,
        to: Date.now(),
});

// load volume profile indicator and set options
let volume_profile = new TradingView.BuiltInIndicator('VbPSessions@tv-volumebyprice-53');

// get study values
volume_profile_study.onUpdate(() => {

        console.log('volume_profile_study.graphic.horizLines.length: ' + volume_profile_study.graphic.horizLines.length); 
});

Am I using range incorrectly here? Thanks for your help!

  • Joe

No it's normal

That is how tradingview is sending data.

commented

Ok I see, so Tradingview is always sending data from the first day of the year you are requesting?
So I have to create multiple requests with different "to" dates. Would be a nice feature if the library could handle this!

Cheers - Joe

commented

Hi Mathieu,

I though I had it, but it seems that "to" is not doing anything.

chart.setMarket('BYBIT:BTCUSD', {
					  
        timeframe: '1D',
        range: 300,
        to: Date.now(),
});

// load volume profile indicator and set options
let volume_profile = new TradingView.BuiltInIndicator('VbPSessions@tv-volumebyprice-53');
let volume_profile_study = new chart.Study(volume_profile);

// get study values
volume_profile_study.onUpdate(() => {

        volume_profile_study.graphic.horizLines.forEach((h) => {
               
              console.log(h);
        });
});

is returning the exact same results as

chart.setMarket('BYBIT:BTCUSD', {
					  
        timeframe: '1D',
        range: 300,
        to: 1600000000000,
});

// load volume profile indicator and set options
let volume_profile = new TradingView.BuiltInIndicator('VbPSessions@tv-volumebyprice-53');
let volume_profile_study = new chart.Study(volume_profile);

// get study values
volume_profile_study.onUpdate(() => {

        volume_profile_study.graphic.horizLines.forEach((h) => {
               
              console.log(h);
        });
});

How do I get data before 1600000000000 (Sun Sep 13 2020 12:26:40 GMT+0000)?

Thanks, Joe

commented

Created a new bug report for my last comment