OPEN-SOURCE SCRIPT

Trendline Detector - 3 Timeframes

77
This advanced Pine Script indicator automatically identifies and draws diagonal support and resistance trendlines across three customizable timeframes simultaneously.
Key Features:

Multi-Timeframe Analysis: Configure three independent sets (A, B, C) to analyze different timeframes on a single chart
Smart Pivot Detection: Identifies local minimums and maximums based on open/close prices rather than wicks, reducing false signals from volatile candle shadows
Automatic Trendline Drawing: Calculates ascending support lines from pivot lows and descending resistance lines from pivot highs
Touch Validation: Only displays trendlines that meet your minimum touch requirements, ensuring statistical significance
Customizable Parameters: Full control over lookback period, pivot window size, deviation tolerance, and minimum touches for each timeframe
Visual Pivot Markers: Optional display of all detected pivot points with color-coded arrows (green for lows, red for highs)
Extended Lines: All valid trendlines extend to the right for forward projection

How It Works:
The indicator scans historical bars within your specified lookback period to identify pivot points. It then evaluates all possible trendline combinations, counting how many price points touch each potential line within your deviation tolerance. The trendline with the most touches (meeting your minimum requirement) is displayed.
Parameter Breakdown:
Each set (A, B, C) includes five critical parameters:

Timeframe: The chart timeframe for analysis (e.g., "1" for 1-minute, "15" for 15-minute, "1D" for daily)
Lookback Bars: How many historical bars to scan for pivot points (default: 250). Higher values capture longer-term trends but may increase computation time.
Min Touches: Minimum number of price touches required for a trendline to be considered valid (default: 3). Higher values ensure stronger, more reliable trendlines but may filter out emerging trends.
Deviation %: Percentage tolerance for what constitutes a "touch" (default: 0.1-1.0%). A 0.5% deviation means prices within 0.5% of the theoretical trendline are counted as touches. Lower values create stricter trendlines; higher values are more forgiving.
Pivot Window: Number of bars on each side used to identify local highs/lows (default: 5). A pivot window of 5 means the center bar must be the highest/lowest among 11 bars total (5 left + center + 5 right). Larger values identify more significant pivots but may miss shorter-term turning points.

Display Options:

Show Min/Max Points: Toggle visibility of pivot point markers to see exactly which price levels the algorithm identified as potential trendline anchors.

Perfect For:

Swing traders looking for multi-timeframe confluence zones
Technical analysts who rely on diagonal support/resistance levels
Traders who want automated trendline detection without manual drawing
Anyone seeking to identify trend channels and breakout opportunities

Color Coding:
Support lines are displayed in green with varying transparency, while resistance lines appear in red. Each timeframe set can be independently enabled/disabled based on which chart timeframe you're currently viewing, preventing clutter and maintaining clarity.
Technical Notes:
The indicator uses efficient algorithms to process large datasets while maintaining accuracy. It avoids repainting by only considering confirmed pivot points. The algorithm prioritizes trendlines with more touches and, in case of ties, favors more recent formations with steeper angles for maximum relevance.

Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.