There are three ways of loading data into an
Framework.$myCandleStore = new FXB.CandleStore();
var candleRequest = { … some candle request … };
Framework.RequestCandles(requestDef, function (Msg) {
if (Msg.candles) {
// Process both an initial response to the candle request
// and also streaming updates with changes and additions
Framework.$myCandleStore.LoadCandles(Msg.candles);
} else {
// No candles[] array. Some problem with the request.
}
});
In addition to setting up event handlers, you can detect changes in the store by looking at the return value from
| Return value | Description |
| -1 | Load failed. Invalid candle data. |
| 0 | No change |
| 1 | Only the current, in-progress candle has changed |
| 2 | A new, latest candle has been added to the store. (As with the OnNewCandle() event, there may also have been a final update to what was previously the current candle.) |
| 4 | Initial load |
| 6 | Load of new candle data which both modifies the history and also adds new current or later candles |
The second way of loading data into the store is to assign the candle store as the second parameter to
// Create a candle store
Framework.$myCandleStore = new FXB.CandleStore();
var candleRequest = { … some candle request … };
// Pass the response(s) from RequestCandles() directly into the FXB.CandleStore,
// without using an asynchronous callback function or needing to process the messages manually:
Framework.RequestCandles(requestDef, Framework.$myCandleStore);
There are two special considerations here, resulting from the fact that you don't receive the response messages from
The framework puts the ID of the candle request into the
If the candle request fails, the framework fires an
The third way of loading candles into a store is to provide a
// Note: this method will only normally be suitable for static candle requests,
// not streaming requests where there are multiple callbacks
var candleRequest = { … some candle request … };
Framework.RequestCandles(requestDef, function (Msg) {
if (Msg.candles) {
// Create a store, populating it with the candles[] array
Framework.$myCandleStore = new FXB.CandleStore({
candles: Msg.candles,
… any other properties you want to assign
});
} else {
// No candles[] array. Some problem with the request.
}
});
You can load candle data of your own into an
Finally, the
UDI.onCalculate = function(data, output) {
var cs = new FXB.CandleStore({candles: data}); // Can also use LoadCandles(data)
};
It's then possible to do things such as extracting derived prices from the store, such as