OPEN-SOURCE SCRIPT
TRI - Layered Multi-Timeframe Support & Resistance

TRI - LAYERED MULTI-TIMEFRAME SUPPORT & RESISTANCE v1.0.0
DESCRIPTION:
Advanced multi-timeframe Support & Resistance indicator using ta.pivothigh/ta.pivotlow
to display pivot-based S/R levels from MULTIPLE timeframes simultaneously on your chart.
Each timeframe has its own configurable color and line width for easy visual distinction.
Features smart pivot positioning, dynamic level merging, retest detection, and comprehensive alert system.
KEY FEATURES:
HOW IT WORKS:
The indicator uses ta.pivothigh() and ta.pivotlow() on each enabled timeframe.
Pivot highs are positioned on bullish candles (using close price).
Pivot lows are positioned on bearish candles (using close price).
If the pivot candle is not the correct type, it searches back up to 5 candles.
Only unbreached levels are displayed as active support/resistance.
When a level is breached, it becomes a "mitigated level" with dashed styling and transparency.
Mitigation is checked only after the first candle following the pivot (to avoid false triggers).
TIMEFRAME FILTERING:
Example on 1h chart: 15m hidden, 1h always shown, 4h/D/W/M per user settings (max 3)
LEVEL MERGING:
Nearby levels of the same type AND same timeframe are automatically merged.
The newer pivot always wins, replacing older levels within the tolerance range.
Tolerance = TF ATR × Merge Tolerance setting (default 0.5 ATR).
VISUALIZATION:
Each timeframe has its own color and line width for easy distinction:
Active levels show as solid lines, mitigated levels as dashed lines with transparency.
Price scale shows level prices with their respective colors.
RETEST DETECTION (Current TF Only):
Detects when price tests a S/R level and bounces back. Two patterns are recognized:
Parameters:
ALERT SYSTEM (Current TF Only):
All alerts trigger only for levels of the current chart timeframe:
SIGNIFICANT BREAKOUT CRITERIA:
A breakout is considered "significant" when:
SETTINGS OVERVIEW:
DESCRIPTION:
Advanced multi-timeframe Support & Resistance indicator using ta.pivothigh/ta.pivotlow
to display pivot-based S/R levels from MULTIPLE timeframes simultaneously on your chart.
Each timeframe has its own configurable color and line width for easy visual distinction.
Features smart pivot positioning, dynamic level merging, retest detection, and comprehensive alert system.
KEY FEATURES:
- Display S/R from multiple timeframes at once (15m, 1h, 4h, D, W, M)
- Each timeframe has independent toggle, color, and line width
- Smart timeframe filtering - never shows TFs lower than current chart
- Current chart TF is always visible (cannot be disabled)
- Configurable max number of higher timeframes to display
- Multi-timeframe pivot detection using ta.pivothigh/ta.pivotlow on candle body
- Smart pivot positioning - pivots placed on correct candle type (bullish for highs, bearish for lows)
- Dynamic level merging - nearby levels merged based on ATR tolerance (newer wins)
- Mitigated level tracking - broken levels shown with dashed style and configurable transparency
- Price scale display - levels shown on price scale with their colors
- Retest detection - identifies bounces off S/R levels (current TF only)
- Comprehensive alert system with 12 alert types (current TF only)
- Significant breakout detection with configurable parameters
- Memory efficient - automatic cleanup of expired levels
HOW IT WORKS:
The indicator uses ta.pivothigh() and ta.pivotlow() on each enabled timeframe.
Pivot highs are positioned on bullish candles (using close price).
Pivot lows are positioned on bearish candles (using close price).
If the pivot candle is not the correct type, it searches back up to 5 candles.
Only unbreached levels are displayed as active support/resistance.
When a level is breached, it becomes a "mitigated level" with dashed styling and transparency.
Mitigation is checked only after the first candle following the pivot (to avoid false triggers).
TIMEFRAME FILTERING:
- Timeframes LOWER than current chart are NEVER shown
- Current chart timeframe is ALWAYS shown (cannot be disabled)
- Higher timeframes respect user toggle settings
- Max higher TFs setting limits how many higher TFs are displayed (default 3)
Example on 1h chart: 15m hidden, 1h always shown, 4h/D/W/M per user settings (max 3)
LEVEL MERGING:
Nearby levels of the same type AND same timeframe are automatically merged.
The newer pivot always wins, replacing older levels within the tolerance range.
Tolerance = TF ATR × Merge Tolerance setting (default 0.5 ATR).
VISUALIZATION:
Each timeframe has its own color and line width for easy distinction:
- 15m - Cyan, width 1
- 1h - Blue, width 1
- 4h - Orange/Gold, width 2
- Daily - Green, width 2
- Weekly - Purple, width 3
- Monthly - Red, width 4
Active levels show as solid lines, mitigated levels as dashed lines with transparency.
Price scale shows level prices with their respective colors.
RETEST DETECTION (Current TF Only):
Detects when price tests a S/R level and bounces back. Two patterns are recognized:
- Pattern 1: Single candle with long wick touching level and body moving away
- Pattern 2: Previous candle touches level, current candle is reaction candle
Parameters:
- ATR Tolerance - How close price must be to level (default 0.15 ATR)
- Min Wick % - Minimum wick size to confirm rejection (default 30%)
ALERT SYSTEM (Current TF Only):
All alerts trigger only for levels of the current chart timeframe:
- New Pivot (any/Support/Resistance) - when new pivot is detected
- Breakout (any/Support/Resistance) - when level is broken with coherent candle
- Significant Breakout (any/Support/Resistance) - high-quality breakouts
- Retest (any/Support/Resistance) - when level is retested with bounce
SIGNIFICANT BREAKOUT CRITERIA:
A breakout is considered "significant" when:
- Candle direction is coherent (bearish for support, bullish for resistance)
- At least X% of the candle body crosses the level (configurable, default 50%)
- Opposite wick is limited to Y% of candle range (configurable, default 30%)
SETTINGS OVERVIEW:
- Global Settings - Max levels per TF, max higher TFs, pivot bars, merge tolerance
- Mitigation Settings - Visibility duration, transparency
- Visual Settings - Circles, labels, price scale
- Timeframe Configuration - Enable/disable, color, line width for each TF
- Significant Breakout - Min body cross %, max opposite wick %
- Retest Detection - ATR tolerance, min wick %
- Debug - Show pivot detection markers
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。