NumericRankArray (Function)

image\trumpet2.gif Disclaimer

The NumericRankArray function returns the rank of a specified price in a sorted data series from an array of values.

Syntax

NumericRankArray(PriceToRank, PriceArray, Size, SortOrder)

Returns (Integer)

The rank (position) of PriceToRank in a array of values that is sorted in either ascending or descending order.  The function returns -1 if PriceToRank is not contained within the specified array, or if the Size is greater than the array that is referenced.

Parameters

Name

Type

Description

PriceToRank

Numeric

Sets the specific price to be ranked within the array.

Price

Numeric

Specifies the array to use for the ranking list.

Length

Numeric

Sets the number of array elements to consider.

SortOrder

Numeric

Sets the sort order for the data series being used for ranking: 1 = Descending; -1 = Ascending.

Remarks

As part of the ranking process, the function creates a sorted list of values using the specified Price series over the last Length bars.  It then looks for the location (rank) of the value PriceToRank in the list.  The exact value of PriceToRank must be found in the price series or the function returns -1.

The NumericRankArray function only works with one-dimensional arrays.  All array-based referencing begins with array element 1.

Example

Assigns to Value1 the rank of a number from a range of values in array myArray with 20 elements.

Array: myArray[20](0);

{… add EL statements here to a range of values to array elements... }

Value1 = NumericRankArray (24, myArray, 20, 2);