A group of functions to work with arrays.

Arrays are allowed to be maximum four-dimensional. Each dimension is indexed from 0 to **dimension size**-1. In a particular case of a one-dimensional array of 50 elements, calling of the first element will appear as array[0], of the last one – as array[49].

Using these functions (except for those which change quantitative and qualitative characteristics of the array) one can process predefined time series Time[], Open[], High[], Low[], Close[], Volume[]

**ArrayBsearch()****ArrayCopy()****ArrayCopyRates()****ArrayCopySeries()****ArrayDimension()****ArrayGetAsSeries()****ArrayInitialize()****ArrayIsSeries()****ArrayMaximum()****ArrayMinimum()****ArrayRange()****ArrayResize()****ArraySetAsSeries()****ArraySize()****ArraySort()**

## ArrayDimension()

int ArrayDimension(object array[])

Returns the multidimensional array rank.

Parameters:

array[] - Array for which the rank will be returned.

Sample:

int num_array[10][5]; int dim_size; dim_size=ArrayDimension(num_array); // dim_size=2

## ArrayGetAsSeries()

bool ArrayGetAsSeries(object array[])

Returns TRUE if array is organized as a series array (array elements are indexed from the last to the first one), otherwise returns FALSE.

Parameters:

array[] - Array to be checked.

Sample:

if(ArrayGetAsSeries(array1)==true) Print("array1 is indexed as a series array"); else Print("array1 is indexed normally (from left to right)");

## ArrayInitialize()

int ArrayInitialize(double &array[], double value)

Sets all elements of a numeric array to the same value. Returns the count of initialized elements.

Note: It is not recommended to initialize index buffers in the custom indicator *init()* function as such functions are initialized automatically with an "empty value" at allocation and re-allocation of buffers.

Parameters:

array[] - Numeric array to be initialized. value - New value to be set.

Sample:

//---- initializing of all array elements with 2.1 double myarray[10]; ArrayInitialize(myarray,2.1);

## ArrayIsSeries()

bool ArrayIsSeries(object array[])

Returns TRUE if the array under check is a series array (Time[],Open[],Close[],High[],Low[], or Volume[]), otherwise returns FALSE.

Parameters:

array[] - Array under check.

Sample:

if(ArrayIsSeries(array1)==false) ArrayInitialize(array1,0); else { Print("Series array cannot be initialized!"); return(-1); }

## ArrayMaximum()

int ArrayMaximum(double array[], int count=WHOLE_ARRAY, int start=0)

Searches for the element with maximum value. The function returns position of this maximum element in the array.

Parameters:

array[] - The numeric array to search in. count - The amount of elements to search in. start - Initial search index.

Sample:

double num_array[15]={4,1,6,3,9,4,1,6,3,9,4,1,6,3,9}; int maxValueIdx=ArrayMaximum(num_array); Print("Max value = ", num_array[maxValueIdx]);

## ArrayMinimum()

int ArrayMinimum(double array[], int count=WHOLE_ARRAY, int start=0)

Searches for the element with minimum value. The function returns position of this minimum element in the array.

Parameters:

array[] - The numeric array to search in. count - The amount of elements to search in. start - Initial search index.

Sample:

double num_array[15]={4,1,6,3,9,4,1,6,3,9,4,1,6,3,9}; int minValueidx=ArrayMinimum(num_array); Print("Min value = ", num_array[minValueIdx]);