You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version 4 is a complete TypeScript rewrite with no compatibility layer. Every v3 capability is still available (see the coverage matrix), under a more consistent API. This page shows how to translate v3 code.
client.send(method, params); the queue is flushed automatically
client.end()
await client.close() (now resolves once actually closed)
new client.Session.Chart()
client.createChart()
new client.Session.Quote(options)
client.createQuoteSession(options)
Charts
v3
v4
chart.setMarket(symbol, { range, to, backadjustment, ... })
chart.setMarket(symbol, { count, to, backAdjustment, ... }) (timeframe, adjustment, session, currency, type, inputs, replay unchanged). The default timeframe is now D (v3: 240). An empty symbol throws instead of loading BTCEUR.
chart.setSeries(timeframe)
chart.setTimeframe(timeframe) (throws INVALID_STATE before setMarket instead of emitting an error)
chart.periods (newest first; max/min; volume rounded to 2 decimals)
chart.candles (oldest first; high/low; raw volume) and chart.lastCandle
chart.infos
chart.symbolInfo
chart.setTimezone(tz)
Same (no longer clears loaded bars)
chart.fetchMore(n)
Same
chart.replayStep/Start/Stop()
Same; they now reject with INVALID_STATE outside replay mode instead of never resolving
v3 passed lists of strings to onError callbacks, or printed them. v4 uses TradingViewError everywhere, with a code (SYMBOL_ERROR, SERIES_ERROR, CRITICAL_ERROR, STUDY_ERROR, AUTH_ERROR, TIMEOUT...), a readable message and the raw server payload in details. Study errors are formatted with their context, e.g. Study error: Invalid value of the 'factor' argument (-1)....
High-level data preview (formerly agent-api)
Preview (agent.js)
v4
fetchCandles({ symbol, timeframe, limit, timeoutMs, signal })
getCandles({ symbol, timeframe, count, timeoutMs, signal })
Provider injection remains: getCandles(query, provider) or watchCandles(query, handlers, provider); client and clientOptions.transport also work for TradingView