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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.