OPEN-SOURCE SCRIPT
已更新 Constant Auto Trendlines (Extended Right)

📈 Constant Auto Trendlines (Extended Right)
This indicator automatically detects market structure by connecting swing highs and lows with permanent, forward-projecting trendlines.
Unlike standard trendline tools that stop at the last pivot, this version extends each trendline infinitely into the future — helping traders visualize where price may react next.
🔍 How It Works
The script identifies pivot highs and lows using user-defined left/right bar counts.
When a new lower high or higher low appears, the indicator draws a line between the two pivots and extends it forward using extend.right.
Each new confirmed trendline stays fixed, creating a historical map of structure that evolves naturally with market action.
Optional filters:
Min Slope – ignore nearly flat trendlines
Show Latest Only – focus on the most relevant trendline
Alerts – get notified when price crosses the most recent uptrend or downtrend line
🧩 Why It’s Useful
This tool helps traders:
Spot emerging trends early
Identify dynamic support/resistance diagonals
Avoid redrawing trendlines manually
Backtest structure breaks historically
⚙️ Inputs
Pivot Left / Right bars
Min slope threshold
Line color, width, and style
Show only latest line toggle
Alert options
This indicator automatically detects market structure by connecting swing highs and lows with permanent, forward-projecting trendlines.
Unlike standard trendline tools that stop at the last pivot, this version extends each trendline infinitely into the future — helping traders visualize where price may react next.
🔍 How It Works
The script identifies pivot highs and lows using user-defined left/right bar counts.
When a new lower high or higher low appears, the indicator draws a line between the two pivots and extends it forward using extend.right.
Each new confirmed trendline stays fixed, creating a historical map of structure that evolves naturally with market action.
Optional filters:
Min Slope – ignore nearly flat trendlines
Show Latest Only – focus on the most relevant trendline
Alerts – get notified when price crosses the most recent uptrend or downtrend line
🧩 Why It’s Useful
This tool helps traders:
Spot emerging trends early
Identify dynamic support/resistance diagonals
Avoid redrawing trendlines manually
Backtest structure breaks historically
⚙️ Inputs
Pivot Left / Right bars
Min slope threshold
Line color, width, and style
Show only latest line toggle
Alert options
版本注释
🆕 Constant Auto Trendlines – Major UpgradeConstant Auto Trendlines x5 (Extended Right) + Slope Labels
What’s new in this update:
✅ Proper Slope Engine
Slope is now calculated correctly as price units per bar using bar_index.
Much more consistent across symbols & timeframes.
📐 Slope Filter (Min Slope)
New input is in ticks per bar, not raw price.
Example: 1.0 = 1 tick per bar (very gentle filter).
Set to 0 to disable filtering and show all lines.
🏷 Slope Labels for Latest Lines
Optional labels on the most recent uptrend & downtrend lines.
Choose how slope is displayed:
Price/Bar
Degrees
ATR/Bar (slope normalised by volatility).
🧠 Cleaner Behaviour
Lines no longer “disappear” unexpectedly when you change Min Slope.
Trendline logic itself is unchanged – only the slope math & display got upgraded.
🎯 Multi-Set Version (x5)
New variant lets you run up to 5 independent trendline sets in one indicator.
Each set has its own:
Pivot Left / Right
Max Lines per side
Min Slope (ticks per bar)
Enable/Disable toggle
Perfect for mixing HTF structure, intraday levels & micro scalper lines without stacking lots of separate indicators.
版本注释
✅ Quick Fix Update – Slope Label Stability PatchFixed a runtime error caused by slope labels referencing bar indices far in the past.
Slope labels now anchor safely at the current bar, eliminating “bar index too far” errors.
Cleaned up indentation + formatting to improve Pine stability.
No functional changes to the trendline logic — just a reliability improvement for users using slope labels.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。