INVITE-ONLY SCRIPT
AI-Powered Support & Resistance levels

AI-Powered Support & Resistance Levels
Overview
This indicator automatically identifies and plots dynamic support and resistance zones using unsupervised machine learning — specifically, a clustering algorithm applied directly to price data. Unlike traditional S/R methods that rely on fixed pivot points, manual drawing, or simple price rounding, this script uses a data-driven approach to discover where price has historically concentrated, and projects those levels as actionable zones on your chart.
How It Works — Underlying Principles
The script follows a multi-step computational process:
What Makes This Different From Standard S/R
Traditional support and resistance tools on TradingView typically use one of these approaches:
This script differs in several key ways:
How To Use
Inputs
Important Notes
Overview
This indicator automatically identifies and plots dynamic support and resistance zones using unsupervised machine learning — specifically, a clustering algorithm applied directly to price data. Unlike traditional S/R methods that rely on fixed pivot points, manual drawing, or simple price rounding, this script uses a data-driven approach to discover where price has historically concentrated, and projects those levels as actionable zones on your chart.
How It Works — Underlying Principles
The script follows a multi-step computational process:
- Price Data Collection: The script collects historical low prices from bearish candles and high prices from bullish candles over a user-defined lookback period (adjustable from 50 to 5000 bars). This separation is intentional: lows from bearish candles and highs from bullish candles represent points where buying or selling pressure was most evident.
- Unsupervised Clustering: A machine learning clustering algorithm groups these collected prices into natural clusters — concentrations of price levels where the market has repeatedly shown interest. The algorithm iteratively assigns each price point to its nearest cluster center, then recalculates each center based on its assigned points. This process repeats until the cluster centers stabilize (converge). The result is a set of price levels that represent statistically significant areas of historical price activity.
- Automatic Cluster Count Optimization: Rather than requiring the user to guess how many S/R zones exist, the script includes a built-in optimization routine that tests multiple cluster counts and automatically selects the number that best balances detail against overfitting. It does this by measuring how well each cluster count explains the variance in the data, and selecting the point of diminishing returns. Users can optionally add extra zones via the "Manual Zone Adjustment" input.
- Volatility-Scaled Zone Width: Each zone's vertical thickness is scaled using ATR(14), so zones automatically adapt to current market volatility. Stronger clusters (containing more price points) produce wider zones, while weaker clusters produce thinner ones. This ensures zones are visually proportional to their statistical significance and remain readable across different instruments and timeframes.
- Role-Reversal Logic: The script applies a role-reversal principle: clustered low-price zones that sit above the current price are displayed as resistance (red), while clustered high-price zones below the current price are displayed as support (green). This reflects the well-established market concept that former support can become resistance and vice versa.
What Makes This Different From Standard S/R
Traditional support and resistance tools on TradingView typically use one of these approaches:
- Pivot highs/lows with a fixed lookback
- Round number levels
- Volume profile or VWAP-based levels
- Manually drawn horizontal lines
This script differs in several key ways:
- Data-driven zone discovery: Zones are not placed at arbitrary pivot points or round numbers. They emerge from the statistical structure of the price data itself through iterative clustering.
- Automatic adaptation: The number of zones, their placement, and their width all adjust automatically based on the data — no manual tuning required.
- Volatility awareness: Zone thickness scales with ATR, so the indicator remains useful whether applied to a low-volatility forex pair or a high-volatility crypto asset.
- Convergence-based accuracy: The clustering algorithm runs until mathematically converged, not for a fixed number of iterations, ensuring stable and reproducible results.
- Proprietary optimization: The method used to determine the optimal number of clusters is a custom implementation that goes beyond simple parameter sweeping.
How To Use
- Apply the indicator to any chart (works on all instruments and timeframes).
- Green zones below price = support. Red zones above price = resistance.
- Wider/more opaque zones indicate stronger historical price concentration (more data points in that cluster).
- Use the "Lookback Period" input to match your trading style: shorter for scalping (50–150 bars), longer for swing/position trading (300–2000 bars).
- Leave "Manual Zone Adjustment" at 0 for fully automatic operation, or increase it to add more granular zones.
- Combine with your own entry/exit methodology — these zones identify where price may react, not how it will react.
Inputs
- Use All Available History: Analyzes up to 5000 bars. Recommended for daily/weekly charts only due to performance considerations.
- Lookback Period: Number of bars to analyze (50–5000). Controls how much historical data feeds into the clustering algorithm.
- Manual Zone Adjustment: Adds extra zones beyond the automatically determined optimal count (0 = fully automatic).
Important Notes
- This indicator identifies zones of historical price interest — it does not predict future price movement.
- No indicator guarantees profitable trades. Always use proper risk management.
- Past performance and historical price patterns do not guarantee future results.
- Best used as a confluence tool alongside your existing trading methodology.
仅限邀请脚本
只有作者授权的用户才能访问此脚本。您需要申请并获得使用许可。通常情况下,付款后即可获得许可。更多详情,请按照下方作者的说明操作,或直接联系hajrashidimadfx。
TradingView不建议您付费购买或使用任何脚本,除非您完全信任其作者并了解其工作原理。您也可以在我们的社区脚本找到免费的开源替代方案。
作者的说明
To request access, send me a private message here on TradingView.
Please do not request access in the comments section.
Payment is handled securely via PayPal.
Once access is granted, you can find the script in your TradingView
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
仅限邀请脚本
只有作者授权的用户才能访问此脚本。您需要申请并获得使用许可。通常情况下,付款后即可获得许可。更多详情,请按照下方作者的说明操作,或直接联系hajrashidimadfx。
TradingView不建议您付费购买或使用任何脚本,除非您完全信任其作者并了解其工作原理。您也可以在我们的社区脚本找到免费的开源替代方案。
作者的说明
To request access, send me a private message here on TradingView.
Please do not request access in the comments section.
Payment is handled securely via PayPal.
Once access is granted, you can find the script in your TradingView
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。