PROTECTED SOURCE SCRIPT
Auto Trendlines

**Overview**
- Automatically draws uptrend and downtrend lines by connecting the latest two pivot highs and pivot lows within a symmetric window.
- Designed for clean, reactive trend visualization with minimal user configuration.
**Features**
- Auto-detection of swing pivots and dynamic line updates on new confirmations.
- Optional right extension for forward projection.
- Built-in line styles: `Solid`, `Dashed`, `Dotted`.
- Customizable colors and line width.
- Lightweight and fast for intraday or higher timeframes.
**Inputs**
- `Calculation Period (odd)`: Window size for pivot detection; must be odd to ensure a unique center bar.
- `Uptrend Line Color`: Color for lines drawn from pivot highs.
- `Downtrend Line Color`: Color for lines drawn from pivot lows.
- `Line Style`: `Solid`, `Dashed`, or `Dotted`.
- `Line Width`: Thickness of the trendlines.
- `Extend Right`: Toggle to extend lines into the future.
**How It Works**
- Uses `ta.pivothigh` and `ta.pivotlow` with symmetric left/right bars derived from the chosen period.
- An odd period guarantees a single center bar (`left = right`), aligning the pivot’s time anchor precisely.
- Once a pivot is confirmed (after the required right bars), the script updates or redraws the uptrend and downtrend lines to connect the last two pivots.
**Notes**
- Larger periods produce smoother, more reliable lines; smaller periods react faster but may be noisier.
- Pivot confirmation requires future bars; lines update when new pivots form, reflecting the most recent structure.
- This script focuses on visual analysis and does not include alerts.
**Compatibility**
- Pine Script v6
- Overlay on price chart (`overlay=true`)
- Optimized for TradingView publication with minimal performance overhead.
**Keywords**
- Trendlines, Auto Trendlines, Pivots, Swing High/Low, Technical Analysis, Pine Script v6
- Automatically draws uptrend and downtrend lines by connecting the latest two pivot highs and pivot lows within a symmetric window.
- Designed for clean, reactive trend visualization with minimal user configuration.
**Features**
- Auto-detection of swing pivots and dynamic line updates on new confirmations.
- Optional right extension for forward projection.
- Built-in line styles: `Solid`, `Dashed`, `Dotted`.
- Customizable colors and line width.
- Lightweight and fast for intraday or higher timeframes.
**Inputs**
- `Calculation Period (odd)`: Window size for pivot detection; must be odd to ensure a unique center bar.
- `Uptrend Line Color`: Color for lines drawn from pivot highs.
- `Downtrend Line Color`: Color for lines drawn from pivot lows.
- `Line Style`: `Solid`, `Dashed`, or `Dotted`.
- `Line Width`: Thickness of the trendlines.
- `Extend Right`: Toggle to extend lines into the future.
**How It Works**
- Uses `ta.pivothigh` and `ta.pivotlow` with symmetric left/right bars derived from the chosen period.
- An odd period guarantees a single center bar (`left = right`), aligning the pivot’s time anchor precisely.
- Once a pivot is confirmed (after the required right bars), the script updates or redraws the uptrend and downtrend lines to connect the last two pivots.
**Notes**
- Larger periods produce smoother, more reliable lines; smaller periods react faster but may be noisier.
- Pivot confirmation requires future bars; lines update when new pivots form, reflecting the most recent structure.
- This script focuses on visual analysis and does not include alerts.
**Compatibility**
- Pine Script v6
- Overlay on price chart (`overlay=true`)
- Optimized for TradingView publication with minimal performance overhead.
**Keywords**
- Trendlines, Auto Trendlines, Pivots, Swing High/Low, Technical Analysis, Pine Script v6
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用它,没有任何限制 — 在此处了解更多信息。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用它,没有任何限制 — 在此处了解更多信息。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。