All indicators

Celestial Mean Reversion Envelopes

Jun 1, 2026

Static chart image
Dynamic OverlaysSignalsChannelsMoving AveragesVolatility

The Celestial Mean Reversion Envelopes indicator identifies mean reversion opportunities by wrapping an adaptive moving average in volatility-based standard deviation envelopes to signal potential price reversals. By dynamically adjusting the baseline speed according to trend intensity, this tool ensures bands remain relevant during both explosive trends and tight consolidations.

Usage

The Usage section describes how the script can be used to identify market extremes and potential entry points. The indicator overlays directly on the price pane, providing a visual representation of overbought and oversold conditions relative to an adaptive mean.

  • Identifying Trends vs. Ranges: The central blue line (Adaptive Mean) indicates market state. A steeply sloping line suggests a strong trend, while a flat line indicates a ranging market.
  • Mean Reversion Signals: A green BUY label appears when the price closes back above the lower band after a breach, suggesting a snap-back to the mean. Conversely, a red SELL label appears when price closes back below the upper band after an upward pierce.
  • Visual Context: The translucent red shading (overbought) and green shading (oversold) help traders visualize the statistical distance of the current price from the adaptive baseline.
  • Confirmation: Signals are designed to fire on a crossunder/crossover basis, meaning the price must actually break the band and سپس return inside it. This provides a one-bar confirmation step to reduce noise from temporary wicks.

Details

The Celestial Mean Reversion Envelopes script utilizes a multi-stage calculation process to ensure the envelopes adapt to market character:

  • Extreme Tracking: The indicator monitors if new highest highs or lowest lows are formed within a specific lookback window.
  • Trend Regularity Adaptive Moving Average (TRAMA) Logic: The script calculates the fraction of recent bars that produced a new extreme and squares this value. This creates a nonlinear smoothing coefficient. In trending markets, the coefficient approaches 1 (making the mean responsive); in ranging markets, it nears 0 (freezing the mean).
  • Volatility-Scaled Envelopes: Instead of using fixed percentages or ATR multiples, the bands are placed at a distance determined by the standard deviation of the price. This ensures the bands expand during high volatility and contract during quiet periods.

Settings

Core Settings

  • Adaptive Mean Length: The lookback window used for tracking extremes and calculating the standard deviation. Higher values create a slower mean and wider bands, while lower values increase sensitivity.
  • Envelope Multiplier: Determines the width of the standard deviation bands. Increasing this value requires price to make a larger move before triggering a signal.
  • Source: The price data used for all calculations (default is "close").

Aesthetics & Colors

  • Bullish Reversion (Buy): Customizes the color of the lower band and buy signals.
  • Bearish Reversion (Sell): Customizes the color of the upper band and sell signals.
  • Mean Baseline: Sets the color of the central adaptive moving average.
  • Show Gradient Fills: Toggles the background shading between the mean and the outer bands.

FAQ

How do I use the Celestial Mean Reversion Envelopes for alerts? You can set alerts using the "Buy Alert" or "Sell Alert" conditions in the indicator's alert panel. It is recommended to use the "Once Per Bar Close" setting to ensure the signal is confirmed by a candle close.

Why does the middle line sometimes stop moving? The middle line is an adaptive mean that "freezes" during consolidation phases where no new price extremes (highest highs or lowest lows) are being met. This prevents the bands from lagging too far behind or giving false signals during sideways price action.

How can I access this indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.