high[1] > high[2] and high[1] > high is true on the bar after the pivot. On a forming bar high still
moves, so the test can pass and later fail; barstate.isconfirmed waits for the close. Keep the last pivot’s bar and price in
static variables, and when the next pivot comes draw a line from the old one to it. line.new is a drawing, so it may sit inside an
if.
- The pivot is on bar
bar_index - 1, so that is thexof the line’s end. A bar index is whatline.newtakes by default. - On the first bars
high[2]isna, the comparison isna, and anifonnadoes not run. - A pivot low is the mirror:
low[1] < low[2] and low[1] < low. - Each line is a drawing, and a script keeps 50 of each kind unless
max_lines_countsays more (see Lines, labels, boxes and polylines and Limits).
talib.highest and talib.lowest give the extremes of a window. See
Referencing previous bars for what high[1] reads.