Calculates pivot high points based on user-defined left and right leg lengths and displays up to a specified number of recent pivot high labels on the main chart pane.
//@version=4
MAX_LABELS = 100
study("Show Last n High Pivots", "", true, max_labels_count = MAX_LABELS)
i_pivotCount = input(5, "How many pivots to show", minval = 0, maxval = MAX_LABELS)
i_pivotLegs = input(3, "Pivot legs", minval = 1, maxval = 5)
// Format price to tick precision.
f_tickFormat() =>
_s = tostring(syminfo.mintick)
_s := str.replace_all(_s, "25", "00")
_s := str.replace_all(_s, "5", "0")
_s := str.replace_all(_s, "1", "0")
// Create an array containing the user-selected max count of label ids.
var labelIds = array.new_label(i_pivotCount)
pHi = pivothigh(i_pivotLegs, i_pivotLegs)
if not na(pHi)
// New pivot found; plot its label `i_pivotLegs` bars back.
pLabel = label.new(bar_index[i_pivotLegs], pHi, tostring(pHi, f_tickFormat()), textcolor = color.white)
// Queue the new label's id by appending it to the end of the array.
array.push(labelIds, pLabel)
// De-queue the oldest label id from the queue and delete the corresponding label.
label.delete(array.shift(labelIds))
Overview
Show Last n High Pivots utilizes an array queue to track active label IDs, automatically deleting older labels when new pivots form to keep the chart clean. Price values on labels are formatted according to symbol tick precision.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
How many pivots to show
int
5
i_pivotCount
Pivot legs
int
3
i_pivotLegs
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us
This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and
This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale
This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur
The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on
This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up