OPEN-SOURCE SCRIPT
Aggiornato 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
Note di rilascio
🆕 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.
Note di rilascio
✅ 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.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.