Multi-Dimensional Arrays

Arrays are tables of variables that store multiple values simultaneously. Think of an array as a spreadsheet with a predetermined number of cells. For example, an array that has 6 cells (which in an array are called elements) will look like one column in a spreadsheet document that has 6 rows. This is a one-dimensional array. However, you can define arrays with multiple dimensions. For example, you can define a two-dimensional array, which will look like a spreadsheet with multiple columns and rows. Or, you can define an array with three dimensions, which will look like a two-dimensional array with multiple sheets - each sheet having multiple rows and columns. You can define an array with up to 10 dimensions.

Multi –dimensional arrays may be store numeric values, true/false values or text.  But each array can only store one of these types of values, according to how the values in the array are initialized.

  All array-based function calculations begin with array element 1.

Syntax

Array: MyArray[L,M](N);

MyArray is a user-declared name for the array, which can be a total of 20 characters in length.

L specifies the maximum array index element that may be addressed for the 1st dimension of a two dimensional array (Note The actual size of the  dimension is L+1 because array indexing begins with element 0).

M specifies the maximum array index element that may be addressed for the 2nd dimension of a two dimensional array (Note The actual size of the dimension is M+1 because array indexing begins with element 0).

N is the initial value of all the elements in the array.  It can be either numeric, true/false or text.

Example

Array: MyNumericArray[100, 5] (0);

Var: BarCounter(0);

if High > Highest(High,10)[1] and BarCounter < 100 then begin

BarCounter = BarCounter + 1;

MyNumericArray[BarCounter,1] = High;

MyNumericArray[BarCounter,2] = Low;

MyNumericArray[BarCounter,3] = Open;

MyNumericArray[BarCounter,4] = Close;

MyNumericArray[BarCounter,5] = BarNumber;

end;

This example declares a 2-dimensional array containing 101 by 6 elements. In this example, all of the elements in MyNumericArray are initialized to a value of 0. Once declared, the size of the array cannot be changed; whatever dimensions the array is created with will be constant throughout the EasyLanguage procedure. When a new 10 bar high is detected, this example saves 4 bar prices (High, Low, Open, Close) and the BarNumber into array elements [BarCounter,1] through [BarCounter,5] of MyNumericArray. This example can save bar data for up to 100 bars (the max size of the 1st dimension).