Skip to main content

Interface: IDatafeedChartApi

Charting Library.IDatafeedChartApi

Methods

getBars

getBars(symbolInfo, resolution, periodParams, onResult, onError): void

This function is called when the chart needs a history fragment defined by dates range.

Parameters

NameTypeDescription
symbolInfoLibrarySymbolInfoA SymbolInfo object
resolutionResolutionStringResolution of the symbol
periodParamsPeriodParamsAn object used to pass specific requirements for getting bars
onResultHistoryCallbackCallback function for historical data
onErrorErrorCallbackCallback function whose only argument is a text error message

Returns

void


getMarks

getMarks(symbolInfo, from, to, onDataCallback, resolution): void

The library calls this function to get marks for visible bars range. The library assumes that you will call onDataCallback only once per getMarks call.

A few marks per bar are allowed (for now, the maximum is 10). The time of each mark must match the time of a bar. For example, if the bar times are 2023-01-01, 2023-01-08, and 2023-01-15, then a mark cannot have the time 2023-01-05.

Remark: This function will be called only if you confirmed that your back-end is supporting marks (DatafeedConfiguration.supports_marks).

Parameters

NameTypeDescription
symbolInfoLibrarySymbolInfoA SymbolInfo object
fromnumberUnix timestamp (leftmost visible bar)
tonumberUnix timestamp (rightmost visible bar)
onDataCallbackGetMarksCallback<Mark>Callback function containing an array of marks
resolutionResolutionStringResolution of the symbol

Returns

void


getServerTime

getServerTime(callback): void

This function is called if the supports_time configuration flag is true when the chart needs to know the server time. The library expects a callback to be called once. The time is provided without milliseconds. Example: 1445324591.

getServerTime is used to display countdown on the price scale. Note that the countdown can be displayed only for intraday resolutions.

Parameters

NameType
callbackServerTimeCallback

Returns

void


getTimescaleMarks

getTimescaleMarks(symbolInfo, from, to, onDataCallback, resolution): void

The library calls this function to get timescale marks for visible bars range. The library assumes that you will call onDataCallback only once per getTimescaleMarks call.

Remark: This function will be called only if you confirmed that your back-end is supporting marks (DatafeedConfiguration.supports_timescale_marks).

Parameters

NameTypeDescription
symbolInfoLibrarySymbolInfoA SymbolInfo object
fromnumberUnix timestamp (leftmost visible bar)
tonumberUnix timestamp (rightmost visible bar)
onDataCallbackGetMarksCallback<TimescaleMark>Callback function containing an array of marks
resolutionResolutionStringResolution of the symbol

Returns

void


getVolumeProfileResolutionForPeriod

getVolumeProfileResolutionForPeriod(currentResolution, from, to, symbolInfo): ResolutionString

The library calls this function to get the resolution that will be used to calculate the Volume Profile Visible Range indicator.

Usually you might want to implement this method to calculate the indicator more accurately. The implementation really depends on how much data you can transfer to the library and the depth of data in your data feed. Remark: If this function is not provided the library uses currentResolution.

Parameters

NameTypeDescription
currentResolutionResolutionStringResolution of the symbol
fromnumberUnix timestamp (leftmost visible bar)
tonumberUnix timestamp (rightmost visible bar)
symbolInfoLibrarySymbolInfoA Symbol object

Returns

ResolutionString

A resolution


resolveSymbol

resolveSymbol(symbolName, onResolve, onError, extension?): void

The library will call this function when it needs to get SymbolInfo by symbol name.

Parameters

NameTypeDescription
symbolNamestringSymbol name or ticker
onResolveResolveCallbackCallback function returning a SymbolInfo (LibrarySymbolInfo)
onErrorErrorCallbackCallback function whose only argument is a text error message
extension?SymbolResolveExtensionAn optional object with additional parameters

Returns

void


searchSymbols

searchSymbols(userInput, exchange, symbolType, onResult): void

Provides a list of symbols that match the user's search query.

Parameters

NameTypeDescription
userInputstringText entered by user in the symbol search field
exchangestringThe requested exchange. Empty value means no filter was specified
symbolTypestringType of symbol. Empty value means no filter was specified
onResultSearchSymbolsCallbackCallback function that returns an array of results (SearchSymbolResultItem) or empty array if no symbols found

Returns

void


subscribeBars

subscribeBars(symbolInfo, resolution, onTick, listenerGuid, onResetCacheNeededCallback): void

The library calls this function when it wants to receive real-time updates for a symbol. The library assumes that you will call the callback provided by the onTick parameter every time you want to update the most recent bar or to add a new one.

Parameters

NameTypeDescription
symbolInfoLibrarySymbolInfoA SymbolInfo object
resolutionResolutionStringResolution of the symbol
onTickSubscribeBarsCallbackCallback function returning a Bar object
listenerGuidstring
onResetCacheNeededCallback() => voidFunction to be executed when bar data has changed

Returns

void


subscribeDepth

subscribeDepth(symbol, callback): string

Trading Platform calls this function when it wants to receive real-time level 2 (DOM) for a symbol. Note that you should set the BrokerConfigFlags.supportLevel2Data configuration flag to true.

Parameters

NameTypeDescription
symbolstringA SymbolInfo object
callbackDOMCallbackFunction returning an object to update Depth Of Market (DOM) data

Returns

string

A unique identifier that will be used to unsubscribe from the data


unsubscribeBars

unsubscribeBars(listenerGuid): void

The library calls this function when it doesn't want to receive updates anymore.

Parameters

NameTypeDescription
listenerGuidstringid to unsubscribe from

Returns

void


unsubscribeDepth

unsubscribeDepth(subscriberUID): void

Trading Platform calls this function when it doesn't want to receive updates for this listener anymore. Note that you should set the BrokerConfigFlags.supportLevel2Data configuration flag to true.

Parameters

NameTypeDescription
subscriberUIDstringA string returned by subscribeDepth

Returns

void