By GoldenStar
callback
: function(configurationData)
configurationData: object
{value: String, name:String, desc:String}
{value: string, name: string}
supported_resolutions = undefined
or
supported_resolutions = []
returns default resolution content.
ex: ["1", "15", "240", "D", "6M"]
gives "1 minute, 15 minutes, 4 hours, 1 day, 6 months" in resolution widget.
ex: ["USD", "EUR", "GBP"]
.
id: string. Unique id
name: string. Short name
description : string. Description
Boolean showing whether your datafeed supports marks on bars or not.
Boolean showing whether your datafeed supports timescale marks or not.
Set this one to true
if your datafeed provides server time (unix time). It is used to adjust Countdown on the Price scale.
Set it if you want to group symbols in the symbol search. Represents an object where keys are symbol types and values are regular expressions (each regular expression should divide an instrument name into 2 parts: a root and an expiration).
ex:
{
"futures": `/^(.+)([12]!|[FGHJKMNQUVXZ]\d{1,2})$/`,
"stock": `/^(.+)([12]!|[FGHJKMNQUVXZ]\d{1,2})$/`,
}
It is applied to the instruments with futures
and stock
as a type
.
userInput
: string. It is text entered by user in the symbol search field.exchange
: string. The requested exchange (chosen by user). Empty value means no filter was specified.symbolType
: string. The requested symbol type:index
,stock
,forex
, etc (chosen by user). Empty value means no filter was specified.onResultReadyCallback
: function(result)result
: array (see below)
[
{
symbol: "<short symbol name>",
full_name: "<full symbol name>", // e.g. BTCE:BTCUSD
description: "<symbol description>",
exchange: "<symbol exchange name>",
ticker: "<symbol ticker name, optional>",
type: "stock", // or "futures" or "bitcoin" or "forex" or "index"
},
];
symbolName
: string. Symbol name orticker
if provided.onSymbolResolvedCallback
: function(SymbolInfo)onResolveErrorCallback
: function(reason)extension
: optional object with additional parameters. It has the following fields:currencyCode
: string. It may be provided to indicate the currency for conversion ifcurrency_codes
configuration field is set andcurrency_code
is provided in the original symbol information. Read more aboutcurrency conversion
.unitId
: string. It may be provided to indicate the unit for conversion ifunits
configuration field is set andunit_id
is provided in the original symbol information.
4. getBars(symbolInfo, resolution, periodParams, onHistoryCallback, onErrorCallback) !!!!Important//Neccessary
symbolInfo
: objectresolution
: stringperiodParams
: object with the following fields:from
- unix timestamp, leftmost required bar time (inclusive end)countBack
- the exact amount of bars to load, should be considered a higher priority thanfrom
if your datafeed supports it (see below). It may not be specified if the user requests a specific time period.to
: unix timestamp, rightmost required bar time (not inclusive)firstDataRequest
: boolean to identify the first call of this method. When it is set totrue
you can ignoreto
(which depends on browser'sDate.now()
) and return bars up to the latest bar.
onHistoryCallback
: callback function for historical data. It should be called just once. This function has 2 arguments:- Array of
bars
. See below. Meta information
: See below.
- Array of
onErrorCallback
: callback function for errors. The only argument of this function is a text error message.
This function is called when the chart needs a history fragment defined by dates range.
Bar
is an object with the following fields:
time
: number. Amount of milliseconds since Unix epoch start in UTC timezone.open
: number. Bar's open valuehigh
: number. Bar's high valuelow
: number. Bar's low valueclose
: number. Bar's close valuevolume
: number. Bar's volume value
Meta information
is an object with the following fields:
noData
: boolean. This flag should be set if there is no data in the requested period.nextTime
: unix timestamp (UTC). Time of the next bar in the history. It should be set if the requested period represents a gap in the data. Hence there is available data prior to the requested period.
from
parameter was and remains inaccurate, since it does not fully take into account the trading session of the symbol. The reason for an inaccurate calculation is speed (an accurate calculation has a linear time complexity, and an inaccurate calculation has a constant complexity).
countBack
the minimum number of bars that the chart needs (it can be slightly larger) to fill the visible range (except for Japanese charts), and along with the to
date (which is the date of the last loaded bar), you can easily provide required data in just one request.
It is recommended to consider the priority of countBack
higher than the priority of from
, i.e. you must return data in the range [from, to)
, but the number of bars should not be less than countBack
. If the number of bars is less than countBack
, the chart will call getBars
again.
If your data provider can return the exact amount of bars, it is preferable to use countBack
over the from
date for greater efficiency:
5. subscribeBars(symbolInfo, resolution, onRealtimeCallback, subscriberUID, onResetCacheNeededCallback)
symbolInfo
: objectresolution
: stringonRealtimeCallback
: function(bar)bar
: object{time, close, open, high, low, volume}
subscriberUID
: objectonResetCacheNeededCallback
(since version 1.7): function() to be executed when bar data has changed
subscriberUID
: object
Optional.
symbolInfo
: objectfrom
: unix timestamp (UTC). Leftmost visible bar's time.to
: unix timestamp (UTC). Rightmost visible bar's time.onDataCallback
: function(array ofmark
s)resolution
: string
mark
is an object that has the following properties:
id
: unique mark IDtime
: unix time, UTCcolor
:red
|green
|blue
|yellow
|{ border: '#ff0000', background: '#00ff00' }
text
: mark popup textlabel
: a letter to be printed on a marklabelFontColor
: color of a letter on a markminSize
: minimum mark size (diameter, pixels) (default value is5
)
Optional.
symbolInfo
: objectfrom
: unix timestamp (UTC). Leftmost visible bar's time.to
: unix timestamp (UTC). Rightmost visible bar's time.onDataCallback
: function(array ofmark
s)resolution
: string
mark
is an object that has the following properties:
id
: unique mark ID.time
: unix time, UTCcolor
:red
|green
|blue
|yellow
| ... |#000000
label
: a letter to be printed on a mark. Single charactertooltip
: array of text strings. Each element of the array is a new text line of a tooltip.
callback
: function(unixTime)
Optional.
currentResolution
: string. Currently selected resolution on the chartfrom
: unix timestamp (UTC). Time of the leftmost visible barto
: unix timestamp (UTC). Time of the rightmost visible barsymbolInfo
: object