My.Array category contains all ARRAY built-in functions available in Overbasic.
Clone #
Returns a copy of the array passed as an argument.
Result type: Same as the array to be cloned.
Arguments:
- DATA ARRAY: any array function or variable (e.g. Open, High, Low, Close, Volume, Indicators, etc.)
Example:
Dim a As Numeric() = My.Array.Clone(Close)
CreateArray #
Creates an array from an expression. The array contains the result of the expression calculated for each single period of data series.
Result type: a numeric array or a number depending on the context.
Arguments:
- EXPRESSION: any numeric expression composed of data functions (e.g. Open, High, Low, Close, Volume), indicator functions, numbers, properties.
Examples:
'In the following context, CreateArray returns a numeric Array:
Dim a As Numeric() = My.Array.CreateArray((Close + High + Low) / 3)
'In the following context, CreateArray returns the value of EXPRESSION in the current bar:
If (My.Array.CreateArray((Close + High + Low) / 3) > Open) Then
...
EndIF
HShift #
Shifts the numeric array passed as an argument horizontally to the right or left by the Offset value.
Result type: a numeric array or a number depending on the context.
Arguments:
- EXPRESSION: any numeric expression composed of data functions (e.g. Open, High, Low, Close, Volume), indicator functions, numbers, properties.
- OFFSET: numeric value specifying the horizontal displacement offset. Positive values will shift the array to the right, negative values to the left.
Examples:
'In the following context, HShift returns a numeric Array shifted right by 10 bars:
Dim a As Numeric() = My.Array.HShift((Close + High + Low) / 3, 10)
Dim a As Numeric() = My.Array.HShift(Close, 10)
'In the following context, HShift returns the value of EXPRESSION in the current bar shifted to the right by 10 bars:
If (My.Array.HShift((Close + High + Low) / 3, 10) > Open) Then
...
EndIF
'Example:
'Assuming Expression equal to:
'3, 5, 34, 67, 88, 23, 65, 25, 88, 3, 123, 344, 545, 1, 12, 3, 456, 345
'and Offset equal to 10, the result will be:
'0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 34, 67, 88, 23, 65, 25
Lbound #
Returns the index of the first element of the array passed as an argument. In Overbasic, all arrays always start at index ZERO. Therefore the result of this function will always be ZERO.
Result type: an integer.
Arguments:
- DATA ARRAY: any array function or variable (e.g. Open, High, Low, Close, Volume, Indicators, etc.)
Dim i As Numeric = My.Array.Lbound(Close)
Ubound #
Returns the index of the last element of the array passed as an argument.
Result type: an integer.
Arguments:
- DATA ARRAY: any array function or variable (e.g. Open, High, Low, Close, Volume, Indicators, etc.)
Dim i As Numeric = My.Array.Ubound(Close)
VShift #
Vertically shifts the numeric array passed as an argument by the Offset value.
Result type: a numeric array or a number depending on the context.
Arguments:
- EXPRESSION: any numeric expression composed of data functions (e.g. Open, High, Low, Close, Volume), indicator functions, numbers, properties.
- STARTING FROM: index of the first element to shift.
- OFFSET: numeric value to add to all array elements. Positive values will shift the array up (offset will be added to each element value), negative values will shift the array down (offset will be subtracted from the value of each element).
- OFFSET TYPE: represents the displacement calculation method:
- P = Point (the offset is directly added to the element value)
- C = Percentage (the offset is calculated for each array element as a percentage of the element value)
Examples:
'VShift returns a numeric array shifted up 10 units starting at zero-index element:
Dim a As Numeric() = My.Array.VShift(Close, 0, 10, "P")
'Example:
'Array: 25, 10, 40, 34, 67
'Result: 35, 20, 50, 44, 77
'VShift returns a numeric array shifted up by 10% of the value of each individual element starting from zero-index element:
Dim a As Numeric() = My.Array.VShift(Close, 0, 10, "C")
'Example:
'Array: 25, 10, 40, 34, 67
'Result: 27.5, 11, 44, 37.4, 73.7