tradingview / charting-library-tutorial

This tutorial explains step by step how to connect your data to the Charting Library
MIT License
397 stars 306 forks source link

Problem function getBar #86

Closed npt05 closed 9 months ago

npt05 commented 10 months ago

I have question how to know when onResult (HistoryCallback) return successful

romfrancois commented 10 months ago

What do you mean? If you turn debug: true in Widget Constructor for instance, you should be able to see in the logs if the library received data based on the request.

npt05 commented 10 months ago

What do you mean? If you turn debug: true in Widget Constructor for instance, you should be able to see in the logs if the library received data based on the request.

that mean

// This is example of tradingview right const bars = await makeApiRequest(data/histoday?${query}); ... onHistoryCallback(bars, {noData: false,});

// And this is my code getData(..., (bars: Bar[]) => { onHistoryCallback(bars, {noData: false,}); })

I call func onHistoryCallback in my func callback so now when I compare chart I get error "getBars callback is already called before"

My solution is use queue to synchronize the process of getting data and pushing to tradingview library

Ex: functionGetData(..., (bars: Bar[]) => { queue.enqueue(bars) }) const data = this.queue.dequeue() onHistoryCallback(data, {noData: false,});

So I want to know when in History the callback succeeds to push the second symbol Or can give me some solution for this?

romfrancois commented 10 months ago

My solution is use queue to synchronize the process of getting data and pushing to tradingview library

What's the end goal here? In theory you shouldn't have to worry and to handle that process. If you want to plot a symbol's data the library will request them, cache them and display them and will rely on a subscription to update data as there are new ones. Whenever you will change symbol it will manage the subscription of the new symbol and will unsubscribe from the previous one.

npt05 commented 10 months ago

My solution is use queue to synchronize the process of getting data and pushing to tradingview library

What's the end goal here? In theory you shouldn't have to worry and to handle that process. If you want to plot a symbol's data the library will request them, cache them and display them and will rely on a subscription to update data as there are new ones. Whenever you will change symbol it will manage the subscription of the new symbol and will unsubscribe from the previous one.

My problem is that I can't compare chart, First time load chart if I have more two symbol I get error "getBars callback is already called before" and chart can't load

romfrancois commented 10 months ago

Let's start investigate step by step.

Are there errors when plotting either symbol on the chart? Comparing symbols is just displaying 2 symbols at the same time so unless there's a discrepancy with 1 symbol's data you should not have any errors in the console.

npt05 commented 9 months ago

https://github.com/tradingview/charting-library-tutorial/assets/81342710/6da8d449-96e5-4881-a5a6-beb27eb23502

This my error

romfrancois commented 9 months ago

I would first advise you to update the version of the library you're using. Based on what I see it looks quite outdated so best to update to check if any potential issues have not been fixed already. If you don't know your version please type the following in your console:

TradingView.version()

For your information, we are currently on v26.

npt05 commented 9 months ago

My library version is v23 and i think the problem is not related to version because if i code getBar function as per tradingview demo there is no problem but when i integrate my feed i can't compare chart

romfrancois commented 9 months ago

Could you please enable debug: true in Widget Constructor and provide all the logs in a separate text file?

npt05 commented 9 months ago

Yes it here

tradingview.log

romfrancois commented 9 months ago

Going quickly over your logs there are a few things not correct:

SymbolInfo validation: supported_resolutions field contains invalid value: dummy
FEED [AAL.UK|1]: **Requesting data:** [2023-08-01T05:14:11.825Z ... 2023-08-01T10:15:11.825Z, **301 bars**]
FEED [AAL.UK|1]: **Receiving bars: total 6359 bars** in  [2023-07-10T00:59:00.000Z ... 2023-07-31T09:09:00.000Z], requested range: [2023-08-01T05:14:11.825Z ... 2023-08-01T10:15:11.825Z, 301 bars]
npt05 commented 9 months ago

No that's not the problem, as you can see at the beginning of my video i can compare chart but when save chart and after reload can't not load chart,means if first load chart i have more than 1 symbol chart can't load