Pivot (Function)
The Pivot function returns the value of a pivot point and the number of bars ago the pivot occurred.
Syntax
Pivot(Price, Length, LeftStrength, RightStrength, Instance, HiLo, oPivotPrice, oPivotBar)
Returns (Integer)
The oPivotPrice and oPivotBar output parameters return the price value of the pivot point and the number of bars ago it occurred. The Pivot function itself returns a value of 1 if a pivot is found, and -1 if not found.
Parameters
Name |
Type |
Description |
Price |
Numeric |
Specifies which bar value (price, function, or formula) to be considered. |
Length |
Numeric |
Sets the number of bars to consider for the pivot. |
LeftStrength |
Numeric |
Sets the required number of bars on the left side of the pivot bar. |
RightStrength |
Numeric |
Sets the required number of bars on the right side of the pivot bar. |
Instance |
Numeric |
Sets which occurrence (that is, 1 = most recent, 2 = 2nd most recent, and so on) to return. |
HiLo |
Numeric |
Sets which pivot values to return, 1 = High, -1 = Low. |
oPivotPrice |
Numeric |
Outputs the specified bar value at the pivot point. |
oPivotBar |
Numeric |
Outputs the number of bars ago the pivot point occurred. |
Remarks
This function is used to find pivot or swing points. This function allows you to specify variable strength sides, as well as whether the pivot point should be a high or low pivot.
Example
Assigns to Value2 the most recent pivot low price over the last 21 bars and to Value3 the number of bars ago the pivot low occurred using a left strength of 4 and a right strength of 2.
Vars: oPivotPrice(0), oPivotBar(0);
Value1 = Pivot(Low,21,4,2,1,-1,oPivotPrice,oPivotBar);
Value2 = oPivotPrice;
Value3 = oPivotbar;