Loading data into the store fills a candles[] array, and you can read directly from this array:
myCandleStore.LoadCandles(…);
var currentClose = myCandleStore.candles[0].c;
However, it is not safe for you to modify the candles[] array in any way. If you need to do any sort of processing on the data, use GetCandleArray() instead as described below.
The store provides some simple properties for checking its contents:
| Property | Description |
| length | Number of candles in the store (equivalent to candles.length) |
| hasData | Boolean indicating whether there are any candles in the store (length > 0) |
By default, like the framework's array returned from RequestCandles(), the candles in a store are indexed newest-first. Item #0 in the array is the current, in-progress candle. Item #1 is the most recent complete candle. Item #[length-1] is the oldest candle etc.
This is generally the easiest and most processor-efficient way of working with candle data, but you can optionally invert the indexing by setting oldestFirst:true. This can be done either in the initialisation of the store, or at any later time by changing the oldestFirst property of the store.
If you set oldest-first mode, then the store's own candles[] array is unchanged, and continues to have the newest candle in #0. However, oldestFirst does alter the following functions which the store provides:
| Function | Description |
| GetCandleArray() | Returns a copy of the candle array (using .slice(0), which means that it is safe for you to modify the result). The order of the array depends on oldestFirst. |
| GetCandle(idx) | Returns a specific zero-based candle, or null if the index is not valid. The oldestFirst property controls whether idx=0 means the most recent candle or the oldest candle etc. |
| GetValueArray(member) | Helper function which returns an array of a single member from all the candles. For example, GetValueArray("h") returns an array containing all the high prices, and GetValueArray("median") returns all the median prices. |
In other words: setting oldestFirst is only meaningful if you then access the candle data using GetCandleArray() and GetCandle(), rather than reading the candles[] array directly. Setting oldestFirst on the store also affects the indexing of any technical analysis calculations in the store.
You can also look up candles by time:
| Function | Description |
| GetByTime(tm, exact) | Finds the candle which starts with or contains the time tm (specified as a number of milliseconds). |
If exact=true, then tm must exactly match a candle's start time or else GetByTime() returns null. If exact=false, then the following rules apply:
If tm is later than the start of the current candle - in other words, any date into the future - then GetByTime() returns the current candle.
If tm is earlier than the start of the earliest candle, then GetByTime() returns null.
Otherwise, GetByTime() returns the candle where tm is greater or equal to its start but before the start of the next candle.
GetByTime() has no notion of any timeframe which candles cover. For example, if you have hourly candles on a 24x5 market such as forex, and you supply a time over a weekend with exact=false, then what you will get back is the final candle on the preceding Friday. (You can obviously check whether a time actually falls within a candle by adding the timeframe of your data to the candle's start time.)