5.2.3.2Loading value data into a calculation

For value-based calculations, you can load in either a candle array or just any array of numbers. If you use a candle array, then you need to set a member value in the calculation's initialisation, specifying which candle property to use such as the median price (automatically derived from the high and low):

// Create an exponential moving average of the median prices of candles

var myEma = new FXB.ta.EMA({period: 20, member: "median"});

// Load candle data into the calculation

myEma.LoadData([{o:1.2342, h: 1.2347, l: 12341, c: 1.2343}, … ]);

Or you can just load into a value-based calculation an array of the median prices, or of any numeric values at all:

myEma.LoadData([1.2349, 1.2368, 1.2392, 1.2347, … ]);

When you are updating the current data for a value-based calculation, you can supply either a candle object or just the relevant property from the candle. For example:

myEma.UpdateCurrent({o:1.2342, h: 1.2347, l: 12341, c: 1.2343}); // Update with candle

myEma.UpdateCurrent(1.2344); // Update just with median price