5.2.3Loading data into a technical analysis calculation

All the technical analysis calculations are optimised so that they have two functions for loading data:

Property

Description

LoadData(array)

Loads or re-loads the full array of data for the calculation. By default, the array should be ordered so that it is newest-first: the most recent item is in #0 and the oldest item is in #length-1

UpdateCurrent(object)

Updates the value for the current bar/value only. You can also pass an array into UpdateCurrent(), but only the first value, [0], is then used.

In other words, LoadData() does a complete load or replacement of the data for the calculation, whereas UpdateCurrent() is a much faster function for doing updates when only the current value is changing. For example, using hourly candles, a full reload/recalculation is only required once per hour, and the thousands of ticks within an hour can be processed much more efficiently by passing just the new price data to UpdateCurrent().

Both LoadData() and UpdateCurrent() have boolean return values indicating whether the new data was successfully processed. Failure can be because your input data was invalid, for example attempting to load an array of numbers rather than of candles into a bar-based calculation. It can also be because you didn't supply enough data. For example, if you have a 30-period moving average, you must supply at least 30 values in the call to LoadData().