Returns the price of a pivot high once rightbars bars have confirmed it, otherwise na.
ta.pivothigh reports a swing high: a value that is the highest across leftbars bars to its left and rightbars bars to its right. The pivot bar is rightbars bars in the past, so the value only appears that many bars after the peak.
A bar to the left may equal the pivot's value, but each of the rightbars newer bars must be strictly lower. With two arguments the source is high.
Syntax
ta.pivothigh(leftbars: series int/float, rightbars: series int/float) -> series float
ta.pivothigh(source: series int/float, leftbars: series int/float, rightbars: series int/float) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| leftbars | series int/ | required | Number of bars to the left that must not exceed the pivot. A whole number of 0 or more. |
| rightbars | series int/ | required | Number of bars to the right that must be lower. A whole number of 0 or more. |
| source | series int/ | required | Series searched for pivots. Omit it, passing only the two counts, to use high. |
Returns
series float: the pivot's value on the confirming bar, otherwise na.
Remarks
- The value arrives on the confirming bar, rightbars bars after the peak. Plot it with offset = -rightbars to draw the mark on the peak bar. The value itself is final once it appears.
- Compare with
ta.highest, which has no delay but cannot tell a peak from a rising bar.
Example
//@version=6
indicator("Swing highs", overlay = true)
left = input.int(5, "Left bars", minval = 1)
right = input.int(5, "Right bars", minval = 1)
ph = ta.pivothigh(high, left, right)
plotshape(not na(ph), "Pivot high", shape.triangledown, location.abovebar, color.red, offset = -right, size = size.small)See also
Runs on Sidechair