This section describes how to request candle data from the framework. There is a separate section below about features to help you work with that candle data: storing it, adding technical analysis calculations etc.
You can request chart/candle data using
| Parameter | Description |
| requestDef | Details of the candle request: market, timeframe etc |
| callback | Callback function which asynchronously receives the requested data (and then further updates depending on the type of request) |
For example:
// Request latest candles on EUR/USD H1 (a default number of candles filled in by the framework)
Framework.RequestCandles({
instrumentId: "EUR/USD",
timeframe: 3600
}, function (MsgCandles) {
// Function which asynchronously receives the candle data from the framework
});
There are three types of candle request:
The most common: a request for the last N candles up to the current time, e.g. in order to display a trading chart.
A request for the N candles up to a historic point in time, e.g. in order to add further history when a user scrolls back in time on a chart
A request for the candles between start and end dates.
All requests must include an
The list of available timeframes depends on the account and trading back-end which MyTrader is connected to. This information is provided in the account features.
A request for N candles (up to the current time or a specific historic date) can include a
You can specify a start date and/or end date for the candle request using
If you make a request for candles up to the current time then, by default, the request will stream: your callback function will get an initial call with the existing candle data, and will then get further calls on each change in the market price - updating the current candle or adding a new candle. If you don't require streaming, you can turn it off by specifying
In full, the possible properties of a candle request are therefore as follows:
| Property | Type | Description |
| instrumentId | Text | ID of the FXB.Instrument for which you want data |
| timeframe | Integer (timeframe) | Chart timeframe, such as 3600 for H1 |
| count | Integer | Number of candles (not applicable if |
| startDate | Integer (millisecond time value) | Start date for historic request. If provided, must also set |
| endDate | Integer (millisecond time value) | End date for historic request |
| noStreaming | Boolean | Optional flag which can be used to turn off streaming on requests. (Automatic if a request has an |
| requestId | Text | Optional ID for the request, repeated back in messages to the callback function. If not provided, the framework will allocate one automatically. If you want to allocate your own ID, you are recommended to use FXB.utils.GenerateGuid(). |
| timezone | Optional time zone settings for the request. See below. | |
| convertTimes | Boolean | Option to do conversion of UTC times before returning the data. See below. |
Note: the Promise version of the function,