OPEN-SOURCE SCRIPT

Swing High/Low Lines

1 044
This indicator automatically detects swing highs and swing lows on the chart and draws horizontal lines from those points with the following behavior:

Detects Swings: Uses ta.pivothigh() and ta.pivotlow() to find significant turning points based on a configurable number of bars to the left and right.
Draws Horizontal Lines: When a swing high or low is confirmed, it draws a horizontal line starting from the actual swing bar and extending to the right.
Extends Until Hit: The line continues extending to the right as long as price has not revisited that level.
Ends When Price Hits It: As soon as price touches or breaks the level again (using wick or close — your choice), the extending line is deleted and replaced with a fixed horizontal line segment that ends exactly at the bar where price first revisited it.
Visual Differentiation: Active (unbroken) lines are solid and bright. Broken lines turn dashed and faded so you can easily see which levels have already been tested.
Optional Markers: You can toggle on/off triangle markers and labels at the swing points.

In Simple Terms:
This script finds important highs and lows, draws lines from them that keep going right until price comes back and touches them, at which point the line stops extending and becomes a fixed historical level.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.