OPEN-SOURCE SCRIPT
Adaptive Bounds RSI [LuxAlgo]

The Adaptive Bounds RSI indicator utilizes online 1D K-Means clustering to dynamically adapt RSI overbought and oversold bounds based on evolving market conditions. Unlike traditional RSI thresholds (70/30) that remain static, this tool identifies five shifting clusters to better categorize price action into regimes ranging from deep discount to extreme premium.
🔶 USAGE
The indicator provides a more responsive way to identify overextended market conditions by learning from recent RSI distributions. Instead of relying on fixed levels that may be irrelevant in strong trends, the adaptive bounds expand and contract based on the volatility and momentum of the asset.
🔹 Regime Classification
The tool classifies the market into five distinct regimes based on five internal centroids (clusters):
🔹 Signal Markers
The indicator plots circular markers directly on the RSI line when the oscillator crosses the adaptive bounds:
To prevent signal clutter, these markers only reappear once the RSI has returned to cross the 50-level midline, ensuring the market has "reset" before a new overextended signal is generated.
🔶 DETAILS
The core of this indicator is an Online 1D K-Means algorithm. Unlike standard clustering which requires a full dataset, this online version updates its centroids bar-by-bar.
When a new RSI value is calculated, the algorithm determines which of the five centroids is closest to that value. It then shifts that "winning" centroid toward the RSI value by a factor determined by the Learning Rate. This allows the boundaries to "breathe" with the market; in a persistent uptrend, the upper bound will naturally migrate higher to avoid premature overbought signals.
🔶 SETTINGS
🔹 Oscillator Settings
🔹 K-Means Settings
🔹 Visuals
🔶 ALERTS
🔶 USAGE
The indicator provides a more responsive way to identify overextended market conditions by learning from recent RSI distributions. Instead of relying on fixed levels that may be irrelevant in strong trends, the adaptive bounds expand and contract based on the volatility and momentum of the asset.
🔹 Regime Classification
The tool classifies the market into five distinct regimes based on five internal centroids (clusters):
- Extreme Premium (Upper Bound): Represents highly overextended bullish conditions.
- Bullish: The zone between the center and the upper bound.
- Neutral: The area surrounding the 50-level midline.
- Bearish: The zone between the center and the lower bound.
- Deep Discount (Lower Bound): Represents highly overextended bearish conditions.
🔹 Signal Markers
The indicator plots circular markers directly on the RSI line when the oscillator crosses the adaptive bounds:
- A Bullish Marker appears when the RSI crosses below the adaptive lower bound (Deep Discount).
- A Bearish Marker appears when the RSI crosses above the adaptive upper bound (Extreme Premium).
To prevent signal clutter, these markers only reappear once the RSI has returned to cross the 50-level midline, ensuring the market has "reset" before a new overextended signal is generated.
🔶 DETAILS
The core of this indicator is an Online 1D K-Means algorithm. Unlike standard clustering which requires a full dataset, this online version updates its centroids bar-by-bar.
When a new RSI value is calculated, the algorithm determines which of the five centroids is closest to that value. It then shifts that "winning" centroid toward the RSI value by a factor determined by the Learning Rate. This allows the boundaries to "breathe" with the market; in a persistent uptrend, the upper bound will naturally migrate higher to avoid premature overbought signals.
🔶 SETTINGS
🔹 Oscillator Settings
- RSI Length: Determines the lookback period for the underlying Relative Strength Index calculation.
🔹 K-Means Settings
- Learning Rate (K-Means): Controls how quickly the adaptive bounds react to new data. A higher value makes the bounds move faster, while a lower value provides more stable, "sticky" boundaries.
🔹 Visuals
- Lower Bound Color: Sets the color for the lower adaptive boundary and bullish signals.
- Upper Bound Color: Sets the color for the upper adaptive boundary and bearish signals.
- Auto RSI Color: When enabled, the RSI line matches the chart's foreground color.
- RSI Color: Sets the color of the RSI line when "Auto RSI Color" is disabled.
🔶 ALERTS
- Regime Flip: Triggers when the market transitions from a Neutral state into a trending cluster (Bullish or Bearish).
- Lower Bound Cross: Triggers when the RSI crosses into the Deep Discount zone.
- Upper Bound Cross: Triggers when the RSI crosses into the Extreme Premium zone.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Build your own edge with AI: luxalgo.com
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Build your own edge with AI: luxalgo.com
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.