ArrayBsearch ()
ArrayCopy ()
ArrayCopyRates ()
ArrayCopySeries ()
ArrayDimension ()
ArrayGetAsSeries ()
ArrayInitialize ()
ArrayIsSeries ()
ArrayMaximum ()
ArrayMinimum ()
ArrayRange ()
ArrayResize ()
ArraySetAsSeries ()
ArraySize ()
ArraySort ()
int ArrayBsearch (double array [], double value, int count = WHOLE_ARRAY, int start = 0, "int" = MODE_ASCEND direction)
Returns index of first occurrence of value in the first dimension of a range if you find the nearest or if it is not.
The function can be used with string arrays and serial numeric arrays.
Note: Binary search sorted array processes only. To sort arrays using numerical ArraySort () functions.
Parameters
string [] - numeric range search.
value - The value of search.
count - count elements to search. By default search in the sequence.
start - Starting index search. By default search starting from the first element.
direction - Search direction. It may be one of the following values:
MODE_ASCEND looking in the direction forward
MODE_DESCEND looking towards back.
Sample
datetime daytimes [];
"Int" = change: 10, dayshift;
/ / All the Time [] timeseries are sorted in descendant mode
ArrayCopySeries (daytimes, MODE_TIME, symbol (), PERIOD_D1);
if (Time [shift]> = daytimes [0]) dayshift = 0;
elsewhere
{
dayshift = ArrayBsearch (daytimes, Time [shift], WHOLE_ARRAY, 0, MODE_DESCEND);
if (Period ()
Print (TimeToStr (Time [shift]), "fits", dayshift ", day bar opened at"
TimeToStr (daytimes [dayshift]));
int ArrayCopy (object & dest [], Object source [], int start_dest = 0, "int start_source = 0, int count = WHOLE_ARRAY)
Copies one array to another array. Arrays must be same type, but double [], int [], datetime [], color [] and bool [] Arrays can be copied as one type.
Returns true copied elements count.
Parameters
dest [] - Destination array.
source [] - Source array.
start_dest - Starting index for the destination array. By default start index is 0.
start_source - Starting index of the source array. By default start index is 0.
count - count elements to copy. WHOLE_ARRAY default is constant.
Sample
double array1 [] [6];
double array2 [10] [6];
/ / Fill the array with some data
ArrayCopyRates (array1);
ArrayCopy (array2, array1, 0, Bars-9, 10);
/ / Array2 now has the first 10 bars in history
int ArrayCopyRates (double & dest_array [], string symbol = NULL, int period = 0)
Copies rates to the two dimensions of the array RateInfo string table, where the second dimension has 6 elements:
0 - time
1 - open,
2 - low
3 - high,
4 - close
5 - volume.
Note: Usually used to undertake a series pass large blocks of data to DLL functions.
Parameters
dest_array [] - a reference destination of two-dimensional numerical array.
symbol - a symbol name, by default used current chart symbol name.
Period - Time frame, by default used current chart period. It could be any of Time frame enumeration values.
Sample
double array1 [] [6];
ArrayCopyRates (array1 "EURUSD", PERIOD_H1);
Print ("Now the bar", TimeToStr (array1 [0] [0]), "Open", array1 [0] [1]);
int ArrayCopySeries (double and string [], int series_index, string symbol = NULL, int period = 0)
Copies of some series array to another array and returns copied item count.
Note: When series_identifier MODE_TIME is the first parameter must be a DateTime array.
Parameters
string [] - Reference to the destination one-dimensional numerical array.
series_index - Series array identifier. It could be any of Series array identifiers enumeration value.
symbol - a symbol name, by default used current chart symbol name.
Period - Time frame, by default used current chart period. It could be any of Time frame enumeration values.
Sample
datetime daytimes [];
"Int" = change: 10, dayshift;
/ / All the Time [] timeseries are sorted in descendant mode
ArrayCopySeries (daytimes, MODE_TIME, symbol (), PERIOD_D1);
if (Time [shift]> = daytimes [0]) dayshift = 0;
elsewhere
{
dayshift = ArrayBsearch (daytimes, Time [shift], WHOLE_ARRAY, 0, MODE_DESCEND);
if (Period ()
Print (TimeToStr (Time [shift]), "fits", dayshift ", day bar opened at"
TimeToStr (daytimes [dayshift]));
int ArrayDimension (object array [])
Returns array dimension count.
Parameters
string [] - string to get the dimensions count.
Sample
int num_array [10] [5];
int dim_size;
dim_size = ArrayDimension (num_array);
/ / Dim_size is 2
bool ArrayGetAsSeries (object array [])
Returns true if the array is organized as a series array (array elements indexed by last first) otherwise return false.
Parameters
string [] - String to check.
Sample
if (ArrayGetAsSeries (array1) == true)
Print ("array1 is indexed as a series string");
elsewhere
Print ("array1 is indexed normally (from left to right)");
int ArrayInitialize (double and string [], double value)
Sets all elements of a numerical sequence in the same value. Returns initialize element count.
Note: There is useless to initialize in init index baferite custom indicator () function.
Parameters
string [] - Numeric array to initialize.
value - new value to set.
Sample
//---- Setting all elements of the array of 2.1
double myarray [10];
ArrayInitialize (myarray, 2.1);
bool ArrayIsSeries (object array [])
Returns true if the check sequence is a series array (time, open, close, high, low or volume).
Parameters
string [] - String to check.
Sample
if (ArrayIsSeries (array1) == false)
ArrayInitialize (array1, 0);
elsewhere
{
Print ("Series array can not be initialized!");
return (-1);
}
int ArrayMaximum (double array [], int count = WHOLE_ARRAY, int start = 0)
Search element with maximum value and returns that position.
Parameters
string [] - numeric range search.
count - count of scan elements in the array.
Home - Start searching from the start 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]);
int ArrayMinimum (double array [], int count = WHOLE_ARRAY, int start = 0)
Search item with minimum value and returns that position.
Parameters
string [] - numeric range search.
count - count of scan elements in the array.
Home - Start searching from the start index.
Sample
double num_array [15] = {} 4,1,6,3,9,4,1,6,3,9,4,1,6,3,9;
double minValueidx = ArrayMinimum (num_array);
Print ("Minimum value =" num_array [minValueIdx]);
int ArrayRange (object array [], int range_index)
Returning an item count in the indicated dimension of the array. Since indexes are zero-based, the size of dimension greater than 1 is the largest index.
Parameters
string [] - String to check
range_index - Dimension index.
Sample
int dim_size;
double num_array [10,10,10];
dim_size = ArrayRange (num_array, 1);
int ArrayResize (object and array [], int new_size)
Set new size of the first dimension. If success returns the count of all elements contained in the sequence, after resizing, otherwise returns zero sequence is not changed.
Parameters
string [] - array to resize.
new_size - New size for the first dimension.
Sample
double array1 [10] [4];
int element_count = ArrayResize (range, 20);
/ / Element count is 80 elements
bool ArraySetAsSeries (double and string [], bool set)
Sets the order index of the array as series arrays, ie the last element has zero index. Returns previous state.
Parameters
string [] - numeric range to be set.
set - Series flag to be set (true) or decrease (false).
Sample
double macd_buffer [300];
double signal_buffer [300];
int i, limit = ArraySize (macd_buffer);
ArraySetAsSeries (macd_buffer, true);
for (i = 0; i
for (i = 0; i
int ArraySize (object array [])
Returns the number of elements contained in the sequence.
Parameters
string [] - An array of any type.
Sample
int count = ArraySize (array1);
for (int i = 0; i
/ / Do some calculations.
}
int ArraySort (double and string [], int count = WHOLE_ARRAY, int start = 0, "int" = sort_dir MODE_ASCEND)
Types numeric strings from the first dimension. Series arrays can be sorted by ArraySort ().
Parameters
string [] - numeric range to sort.
count - Count of elements to sort.
start - Starting index.
sort_dir - String sort direction. It may be one of the following values:
MODE_ASCEND - sort ascending,
MODE_DESCEND - sort descending.
Sample
double num_array [5] = {4,1,6,3,9};
/ / Now the array contains the values 4,1,6,3,9
ArraySort (num_array);
/ / Now the array is sorted 1,3,4,6,9
ArraySort (num_array, MODE_DESCEND);
/ / Now the array is sorted 9,6,4,3,1



0 comments:
Post a Comment