Extremes (Function)
The Extremes function returns the extreme highest or lowest value over a range of bars and how many bars ago the extreme value occurred. There may be times when two or more bars have the exact same extreme highest or lowest value; when this happens the function identifies the most recent occurrence.
Syntax
Extremes(Price,Length,HiLo,oExtremeVal,oExtremeBar)
Returns (Integer)
The oExtremeVal and oExtremeBar output parameters return the extreme value and the number of bars ago it occurred. The Extremes function itself returns a value of 1.
Parameters
Name |
Type |
Description |
Price |
Numeric |
Specifies which bar value (price, function, or formula) to compare for highest and lowest extremes. |
Length |
Numeric |
Sets the number of bars to consider for extremes. |
HiLo |
Numeric |
Sets whether the function will return the highest or lowest extreme value. 1=Highest, -1=Lowest. |
oExtremeVal |
Numeric |
Outputs the highest or lowest extreme value found for the range of bars based on the HiLo setting. |
oExtremeBar |
Numeric |
Outputs the number of bars ago the extreme value occurred. |
Remarks
The input parameter Price can be a bar value such as Close, High, Low, Open, or Volume. It can also be any mathematical calculation such as: ( High + Low) / 2, or a numeric function such as RSI, Stochastic, or ADX.
See Multiple Output Function for more information on using output parameters to return values.
Example
Assigns to Value2 the highest High of the last 20 bars using the oExtremeVal output parameter, and assigns to Value3 the number of bars ago the highest High occurred using oExtremeBar output parameter. Value1 is assigned a value of 1:
vars: oExtremeVal(0), oExtremeBar(0);
Value1 = Extremes(High, 20, 1, oExtremeVal, oExtremeBar);
Value2 = oExtremeVal;
Value3 = oExtremeBar;