OPEN-SOURCE SCRIPT
Multi Timeframe Support and Resistance

Multi Timeframe Support and Resistance
This indicator detects swing-based support and resistance levels from a user-selected timeframe and plots them as horizontal lines on the current chart. It is designed for use on a lower timeframe chart while sourcing levels from a higher timeframe.
How it works
Pivot highs and pivot lows are calculated on the source timeframe using request.security with lookahead_on. Because gaps_off causes pivot values to repeat until a new pivot fires, the indicator tracks the last seen value and records only genuinely new pivots into separate high and low history arrays.
On the final bar, all stored pivots are processed most-recent-first. A clustering filter discards any new level that falls within a configurable percentage of an already-accepted level, preventing duplicate lines at nearly identical prices. The resulting lists are capped at the configured maximum and drawn as horizontal lines spanning a fixed number of bars to the left and right of the current bar.
Each level is classified as resistance if it is above the current source-timeframe close, or support if it is below. Levels within 1.5% of the current price are drawn with a thicker line and full opacity to highlight nearby key zones.
Settings
Works on any symbol and any chart timeframe. The source timeframe should be equal to or higher than the chart timeframe for meaningful results.
This indicator detects swing-based support and resistance levels from a user-selected timeframe and plots them as horizontal lines on the current chart. It is designed for use on a lower timeframe chart while sourcing levels from a higher timeframe.
How it works
Pivot highs and pivot lows are calculated on the source timeframe using request.security with lookahead_on. Because gaps_off causes pivot values to repeat until a new pivot fires, the indicator tracks the last seen value and records only genuinely new pivots into separate high and low history arrays.
On the final bar, all stored pivots are processed most-recent-first. A clustering filter discards any new level that falls within a configurable percentage of an already-accepted level, preventing duplicate lines at nearly identical prices. The resulting lists are capped at the configured maximum and drawn as horizontal lines spanning a fixed number of bars to the left and right of the current bar.
Each level is classified as resistance if it is above the current source-timeframe close, or support if it is below. Levels within 1.5% of the current price are drawn with a thicker line and full opacity to highlight nearby key zones.
Settings
- Source Timeframe — the timeframe from which pivots are sourced (default: 15m)
- Swing Left Bars — bars to the left required to confirm a pivot (default: 10)
- Swing Right Bars — bars to the right required to confirm a pivot (default: 10)
- Max S/R Lines — maximum number of levels drawn for each side (default: 8)
- Zone Cluster % — minimum percentage distance between two accepted levels (default: 0.5%)
- Line Length (bars) — how many bars left and right each line spans (default: 300)
- Show Labels — toggle S/R labels with timeframe and price on or off
- Resistance Color — color for levels above the current price
- Support Color — color for levels below the current price
- Line Width — base thickness of drawn lines (default: 2)
Works on any symbol and any chart timeframe. The source timeframe should be equal to or higher than the chart timeframe for meaningful results.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。