3.2.1Candle response messages

The framework's response into your callback function will be a message object containing the following properties:

Property

Description

result

FXB.Result object describing whether your request succeeded

requestId

ID of the candle request, either allocated automatically or set by you in your request definition. This can be used to terminate streaming requests.

candles[]

If your request was successful, an array of initial or changed candles

timezone

Time zone used for the candle request. See below. Either repeats a timezone which you specified in your request or, if none, contains the user's default time zone for charts (Framework. GetUserChartTimezone).

For example:

Framework.RequestCandles(requestDef, function (MsgCandles) {

if (MsgCandles.result.isOkay) {

// MsgCandles will contain a candles[] array

} else {

// Some problem with the request; see MsgCandles.result.code

}

});

Each item in a candle array has the following properties:

Candle property

Type

Description

i

Integer (millisecond time value)

Unique time-based index value for the candle. Not necessarily the same as ts. You should use i rather than ts to store/index and update candles.

ts

Integer (millisecond time value)

Start time of the candle - see notes below about time zones. Depending on the back-end system, this is not necessarily the exact start of a timeframe-based period. For example, if you have requested hourly data, then it is possible when connected to some back-end systems for the ts to be e.g. 10:02, if that was the first price movement in the hour, rather than 10:00.

o

Number

Open price

h

Number

High price

l

Number

Low price

c

Number

Close price (current price for current candle)

v

Number

Volume. Not available on all platforms.

The candles[] array is always sorted by time (ts), in descending order - most recent first.

In a streaming request, the following will happen:

Your callback function will receive an initial call with an array of, say, 1000 candles

Each time the price changes, the current candle will update, and your callback function will receive a candles[] array containing a single item: the update to the current candle.

When the price changes and enters a new time period, you will receive a candles[] array containing an item with an i (and ts) which you have not previously received.