Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tradingview chart time order violation error

I create a chart with TradingView library.this is option that i use to init chart :

var widget = window.tvWidget = new TradingView.widget({
    debug: true,
    fullscreen: true,
    symbol: 'WEBT',
    interval: '60',
    height: "142px",
    container_id: "tv_chart_container",
    datafeed: new Datafeeds.UDFCompatibleDatafeed("/tradingview/udf"),
    library_path: "/assets/charting_library/",
    disabled_features: ["use_localstorage_for_settings"],
    charts_storage_api_version: "1.1",
    client_id: 'tradingview.dotnet',
    user_id: 'public_user_id',
    theme: getParameterByName('theme'),
    time_frames: [
        { text: "60", resolution: "60"},
        { text: "1D", resolution: "1D"},
        { text: "1W", resolution: "1W"},
    ],
});

I use UDF to transfer data from server to chart . the UDF return this response :

{"s":"ok","t":[1612432588,1612446988],"c":[10000,9999],"o":[21000,9999],"h":[21000,9999],"l":[10000,9999],"v":[76300,19998]}

after chart loaded I have a error in console :

PutToCacheNewBar: time violation, previous bar time: 2021-02-04T13:56:48.000Z should be less or equal to new time: 2021-02-04T09:56:58.000 
time order violation, prev: Thu, 04 Feb 2021 13:56:48 GMT, cur: Thu, 04 Feb 2021 09:56:58 GMT

and every time UDF loaded volume of candles changed !

like image 461
adib16 Avatar asked Jul 04 '26 05:07

adib16


2 Answers

The putToCacheNewBar error message occurs when a realtime update (from SubscribeBars) gives the chart a new bar which has a time value earlier than the current latest bar. Realtime updates should only update the latest bar (the time is the same), or provide a newer bar (time is later). And it should only provide data for a single bar.

https://github.com/tradingview/charting_library/wiki/JS-Api#subscribebarssymbolinfo-resolution-onrealtimecallback-subscriberuid-onresetcacheneededcallback

like image 52
SlicedSilver Avatar answered Jul 06 '26 19:07

SlicedSilver


Found out when I remove the has_empty_bars: true from resolveSymbol config it seems to work fine.

like image 20
Charles Chiakwa Avatar answered Jul 06 '26 19:07

Charles Chiakwa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!