Mode (Function)
The Mode function returns the most frequently occurring or repetitive value over a specified range of bars.
Syntax
Mode(Price, Length, Type)
Returns (Double)
A numeric value containing the most frequently occurring or repetitive value in a specified period. If there is no repetition in the range of data, the Function will return a -1.
Parameters
|
Name |
Type |
Description |
|
Price |
Numeric |
Specifies which bar value (price, function, or formula) to use. |
|
Length |
Numeric |
Sets the number of bars to consider. |
|
Type |
Numeric |
A numeric value that determines if the higher (1) or lower (-1) of the values will be displayed in the event that there are multiple repetitious values in the data series. |
Examples
Assigns to Value1 the most frequently occurring Close value in the last 21 bars. If there happens to be multiple sets of frequently occurring Close values, the higher valued of the Close sets will be returned.
Value1 = Mode(Close, 21, 1);
Assigns to Value2 the most frequently occurring Range value in the last 30 bars. If there happens to be multiple sets of frequently occurring Range values, lower valued of the Range sets will be returned.
Value2 = Mode(Range, 30, -1);