PivotPoint
Background
A pivot is a local turning point in the data, a high with lower bars on either side or a low with higher bars on either side. Often you don't want every pivot, you just want one particular recent one: the last swing high, the swing low before that, and so on. That is what this function gives you.
PivotPoint walks backwards from the most recent bar, counting pivots as it
goes, and returns the value of the Nth one. So PivotNo of 1 gives
you the value of the most recent pivot, 2 gives the one before it, and so on. If you
want the bar number of that pivot instead of its value, use
PivotPointBar.
Function
PivotPoint(Source, TrendSize, PivotNo)
Parameters
| Parameter | Description |
|---|---|
| Source | The array pivots are found on. This can be the price or another indicator such as RSI. |
| TrendSize | How large the trend on each side of a point has to be for it to count as a pivot. Larger values find fewer, more significant pivots. Must be at least 1. |
| PivotNo | Which pivot you want, counting back from the most recent. 1 is the latest pivot, 2 is the one before it, and so on. |
Usage
// Value of the most recent swing high
lastHigh = PivotPoint( High, 5, 1 );
// Value of the swing high before that
priorHigh = PivotPoint( High, 5, 2 );
Filter = lastHigh > priorHigh; // higher highs
AddColumn( lastHigh, "Last High" );
AddColumn( priorHigh, "Prior High" );
This returns a single value, not an array. If there aren't enough pivots to reach the one you asked for, or there isn't enough clean data, it returns an empty value.