5.1.1Creating a candle store

You can create a candle store simply by creating a new instance of the FXB.CandleStore class. For example:

// Create candle store

var myCandleStore = new FXB.CandleStore();

// Set up candle store

myCandleStore.OnLoad = function() { … };

… further initialisation, load of data etc

After creation, you can use LoadCandles() to load data into the store, assign event handlers, etc.

However, you can also initialise the candle store "inline", rather than setting it up later. For example, rather than creating a candle store and then assigning an OnLoad() handler, you can instead pass some or all properties in the initialisation of the store:

var myCandleStore = new FXB.CandleStore({

OnLoad: function() { … called on (re-)load },

OnNewCandle: function() { … called when a new candle starts },

etc

});

The full set of properties which you can optionally pass in the initialisation is as follows. You can also assign any other properties of your own (provided, obviously, that their names don't overlap with the candle store's own values):

Property

Description

OnCurrentCandleChange()

Event handler. See below.

OnNewCandle()

Event handler. See below.

OnLoad()

Event handler. See below.

OnLoadError()

Event handler. See below.

OnUpdate()

Event handler. See below.

candles[]

Array of candles to populate with. See below.

ta[]

Array of technical analysis calculations to populate with. See below.

oldestFirst

Changes the indexing of the store. See below.