INVITE-ONLY SCRIPT
已更新 Mean Reversion Framework [LTS]

LHAMA Trading Suite's Mean Reversion Framework is a VWAP-centric mean reversion and exhaustion tool that combines volatility regimes, volume-weighted extension zones, and multi-oscillator divergence detection into a single framework. It is designed to help traders quickly answer three questions on any chart:
Core components
1. Adaptive VWAP with standard deviation bands
The framework builds around a dynamically anchored VWAP with statistical bands:
Anchoring is automatic and timeframe-aware. When you change your charts timeframe, this will automatically adjust what VWAP you are looking at to make sure you're always using the anchoring research has shown to be most appropriate and relevant for that timeframe.
2. Reversion candle coloring
To highlight potentially climactic moves:

The ideal reversion setup is a quick extension into the marked zone, which includes a high volume, small body candle at its peak, surrounded by lower volume candles in opposite directions. This shows an energetic push in one direction, followed by exhaustion and a fade back toward the mean.
3. Volatility regime detection
The script classifies the current volatility regime using ATR:
The current regime and ATR percentile are displayed on the dashboard and can be used as context for whether mean-reversion setups may be more or less favorable. Alerts can fire when volatility crosses into high or low regimes so users can adjust expectations or strategies if desired.
4. RSI & Stochastic divergence framework
The indicator includes a combined divergence engine using RSI and Stochastic:
For both RSI and Stochastic, the script looks for:
When conditions are met, the script will:
Divergence labels are based on confirmed pivots, so they appear with a delay relative to the pivot bar. They are not predictive and should be treated as contextual information rather than standalone trade signals.
5. Dashboard overlay
An on-chart dashboard summarizes the most important state variables in a compact table:
The dashboard can be toggled on or off and moved to any corner of the chart (top/bottom, left/right).
6. Alert system & cooldown
The script defines multiple alert conditions so users can build their own rules around mean reversion and volatility changes:
To reduce alert noise around VWAP resets, there is an optional alert cooldown:
Users can disable the cooldown by setting its duration to 0.
- How far is price stretched away from VWAP in standard deviations?
- Is the current environment favorable or hostile to mean reversion?
- Are there momentum divergences supporting a reversal or trend continuation idea?
Core components
1. Adaptive VWAP with standard deviation bands
The framework builds around a dynamically anchored VWAP with statistical bands:
- VWAP line plotted from a rolling anchor point.
- Standard deviation bands: ±1σ, ±2σ, ±2.5σ, and ±3σ around VWAP.
- Extension zones: the area between ±2.5σ and ±3σ is highlighted as an “extension zone,” where price is statistically stretched from its mean.
Anchoring is automatic and timeframe-aware. When you change your charts timeframe, this will automatically adjust what VWAP you are looking at to make sure you're always using the anchoring research has shown to be most appropriate and relevant for that timeframe.
2. Reversion candle coloring
To highlight potentially climactic moves:
- The script tracks a configurable volume average and multiplier.
- When price touches the ±2.5σ extension zone and a candle meets one of these conditions, candles can be recolored:
Has above average volume, but below average candle body size.
Has lower volume than the previous candle. - An optional alert can be triggered when these extension touches occur.
The ideal reversion setup is a quick extension into the marked zone, which includes a high volume, small body candle at its peak, surrounded by lower volume candles in opposite directions. This shows an energetic push in one direction, followed by exhaustion and a fade back toward the mean.
3. Volatility regime detection
The script classifies the current volatility regime using ATR:
- Calculates ATR over a user-defined lookback.
- Computes the percentile rank of current ATR relative to its recent history.
- Labels the environment as:
- HIGH volatility (ATR percentile at or above the high threshold).
- LOW volatility (at or below the low threshold).
- MODERATE otherwise.
- HIGH volatility (ATR percentile at or above the high threshold).
The current regime and ATR percentile are displayed on the dashboard and can be used as context for whether mean-reversion setups may be more or less favorable. Alerts can fire when volatility crosses into high or low regimes so users can adjust expectations or strategies if desired.
4. RSI & Stochastic divergence framework
The indicator includes a combined divergence engine using RSI and Stochastic:
- User-configurable RSI length.
- User-configurable Stochastic K/D parameters.
- Pivot-based detection with left/right lookbacks and a max lookback window.
- Two main categories:
- Regular divergences – potential reversal context.
- Hidden divergences – potential trend continuation context.
- Regular divergences – potential reversal context.
For both RSI and Stochastic, the script looks for:
- Bullish regular: price lower low vs. oscillator higher low.
- Bearish regular: price higher high vs. oscillator lower high.
- Hidden bullish: price higher low vs. oscillator lower low.
- Hidden bearish: price lower high vs. oscillator higher high.
When conditions are met, the script will:
- Plot labels on the price chart:
🔃 icons for regular (reversal) divergences.
⏩ icons for hidden (continuation) divergences. - Combine RSI and Stochastic confirmation into a single label when both agree, with tooltips explaining:
Price structure (HH/HL/LL/LH).
Which oscillator(s) confirmed the divergence.
Whether the pattern suggests potential reversal or continuation. - Optionally trigger alerts for each divergence type when alerts are enabled.
Divergence labels are based on confirmed pivots, so they appear with a delay relative to the pivot bar. They are not predictive and should be treated as contextual information rather than standalone trade signals.
5. Dashboard overlay
An on-chart dashboard summarizes the most important state variables in a compact table:
- VWAP Anchor – shows the effective anchor logic currently in use (“Session/Week/Month”, “5-Day Rolling” or “Yearly (Jan 1)”).
- Alert Status – ACTIVE, COOLDOWN, or DISABLED.
- Volatility Regime – HIGH / MODERATE / LOW with the current ATR percentile.
- VWAP Value – current VWAP price.
- Price vs VWAP – distance of price from VWAP in standard deviations (σ).
- ATR – current ATR value for the selected length.
The dashboard can be toggled on or off and moved to any corner of the chart (top/bottom, left/right).
6. Alert system & cooldown
The script defines multiple alert conditions so users can build their own rules around mean reversion and volatility changes:
- Extension zone alerts:
Price enters upper extension (≥ +2.5σ).
Price enters lower extension (≤ −2.5σ).
Price enters any extension zone.
High-volume candle touching an extension zone. - Divergence alerts:
Regular bullish / bearish divergence.
Hidden bullish / bearish divergence. - Volatility regime alerts:
- ATR percentile crosses into HIGH volatility.
- ATR percentile crosses into LOW volatility.
- ATR percentile crosses into HIGH volatility.
To reduce alert noise around VWAP resets, there is an optional alert cooldown:
- At the start of a new VWAP period (session/5-day/yearly, depending on timeframe), the script can enter a cooldown phase.
- During cooldown, extension-related alerts are temporarily suppressed for a user-defined number of minutes.
- Volatility regime alerts remain active, as they reflect broader structural changes rather than short-term VWAP resets.
Users can disable the cooldown by setting its duration to 0.
版本注释
Updated to adjust default values for better accuracy for new users.版本注释
Clarified tooltip wording仅限邀请脚本
只有作者授权的用户才能访问此脚本。您需要申请并获得使用许可。通常情况下,付款后即可获得许可。更多详情,请按照下方作者的说明操作,或直接联系LHAMA-Trading。
TradingView不建议您付费购买或使用任何脚本,除非您完全信任其作者并了解其工作原理。您也可以在我们的社区脚本找到免费的开源替代方案。
作者的说明
Visit https://lhamatrading.com for access details.
Creators of the LHAMA Trading Suite. Visit lhamatrading.com to unlock all our indicators.
Skip the drama, ride the LHAMA!
Skip the drama, ride the LHAMA!
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
仅限邀请脚本
只有作者授权的用户才能访问此脚本。您需要申请并获得使用许可。通常情况下,付款后即可获得许可。更多详情,请按照下方作者的说明操作,或直接联系LHAMA-Trading。
TradingView不建议您付费购买或使用任何脚本,除非您完全信任其作者并了解其工作原理。您也可以在我们的社区脚本找到免费的开源替代方案。
作者的说明
Visit https://lhamatrading.com for access details.
Creators of the LHAMA Trading Suite. Visit lhamatrading.com to unlock all our indicators.
Skip the drama, ride the LHAMA!
Skip the drama, ride the LHAMA!
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。