NumericRank (Function)

image\trumpet2.gif Disclaimer

The NumericRank function returns the rank of a specified price in a sorted price series.

Syntax

NumericRank(PriceToRank, Price, Length, SortOrder)

Returns (Integer)

The rank (position) of PriceToRank in a price series, as defined by Price and Length, that is sorted in either ascending or descending order. The function returns 0 if PriceToRank is greater than the number of values in the price series.

Parameters

Name

Type

Description

PriceToRank

Numeric

Sets the specific price to be ranked within the Price data series.

Price

Numeric

Specifies which bar value (price, function, or formula) to use for the ranking list.

Length

Numeric

Sets the number of bars 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.

Example

Assigns to Value1 the rank of the current Close over the most recent 5 Closes, sorted in descending order.

Value1 = NumericRank(Close, Close, 5, 1);

Assigns to Value1 the rank of the previous bar’s Range over the most recent 8 bar Ranges, sorted in ascending order.

Value1 = NumericRank(Range[1], Range, 8, -1);

See Also

NthExtremes, NthHighest, NthLowest