Makevalidarray and Heap Object Example

Relative Vigor Index was originally written back in January 2001 using VBScript, with two different sub functions and looping that reference previous bars and get calculated results. NeoTicker have since added new scripting language objects which have improved ease of implementing this kind of calculation.

This article will include source codes from VBScript and Delphi Script, as a reference original VBScript implementation is included so comparison can be make of the new and old implementation.

New Delphi Script and VBScript implementation will show case use of makevalidarray and heap objects.

Makevalidarray is used when indicator need to reference a set number of historical bars during its calculation. Makevalidarray will ensure all historical data value return with valid values when there are invalid bars in between.

Makevalidarray is required in this indicator because Value1 and Value2 calculation have to reference Open, High, Low and Close of four historical data bars, calling Makevalidarray ensure historical data request return valid values even when there are invalid bars in between.

Heap is used to store historical calculation for subsequent use.

Two heap.reallist array are used to store calculated result from previous N bars, these two heap array replaced the function calls which will help improve performance.


Blog Developed
By ContentRobot