OPEN-SOURCE SCRIPT
Swing High/Low Lines

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.
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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.