Array Usage

Arrays are often used with loops to store values based on successive calculations that use a counter as an index number. Because EasyLanguage allocates space for each index number, avoid declaring an array larger than necessary.  

Examples

Usage Example: (Single-Dimension Array Declaration)

Array: WeeklyHighs[52](0), WeeklyLow[52](0)

(declares a  single dimension 53 element array, 0 to 52, and initializes each element to 0)

 

Usage Example: (Assigning Values to a Single-Dimension Array in a Loop)

Var: x(0);

Array: PrevCloses[5](0);

For x = 1 to 5 begin

PrevCloses[x] = Close[x];

End;

 

Usage Example: (Retrieving Values from a Single-Dimension Array in a Loop)

Var: x(0), SumCloses(0);

Array: PrevCloses[5](0);

SumCloses = 0;

For x = 1 to 5 begin

SumCloses = SumCloses + PrevCloses[x];

End;

 

Usage Example: (Multidimensional Array Declaration)

Array: VolumeHighs[5,20](0), VolumeLows[5,20](0);

(declares a  two dimensional array,  6 elements by 21 elements, or 126 elements, and initializes each element to 0)

See Multi-Dimensional Arrays for more information.

 

  Remember to avoid using data element 0 if you are going to use any of the built-in array functions.

Array names like variables are unique to the study they are declared in; you can use the same name over again in any other study, but you cannot use the same name within the same study, for example, declaring a array with the same name as an variable. Also, remember to avoid naming arrays with the same name as an EasyLanguage reserved word.

Related Topics

Multi-Dimensional Arrays

Array (Reserved Word)   same as Arrays

Fixed Length Arrays