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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。