Skip to main content

What this builds

  • Automatic swing high and swing low detection
  • Each pivot gets a Line entity with style: "arrow.right" that projects forward
  • Price label on each line

Full script

Dynamic keys

Each pivot gets its own unique key (sr_high_${pivotBar}) so old lines persist on the chart while new ones are added. This means the chart can accumulate many lines over time - use maxLines logic (not shown above) or a fixed-size key pool if you want to cap line count.

Capping old lines

To limit lines to the most recent maxLines pivots, maintain a counter and delete old ones:

Pivots

ta.pivothigh/pivotlow - the lag explained.

Line entity

Full Line options including arrow.right style.

str.*

str.format for price labels.