All indicators

Mean Reversion Cloud (Ornstein-Uhlenbeck)

Sep 25, 2024

Static chart image
Dynamic OverlaysSignalsDashboardMoving AveragesVolatility

The Mean Reversion Cloud (Ornstein-Uhlenbeck) tool identifies potential mean-reversion opportunities by applying the Ornstein-Uhlenbeck stochastic process to asset prices. This indicator calculates a dynamic long-term mean using an Exponential Weighted Moving Average (EWMA) and surrounds it with volatility-based bands to signal overbought or oversold conditions.

Usage

The Usage section focuses on interpreting the visual elements and signals generated by the cloud and its statistical components.

  • Mean Reversion Signals: Look for price interactions with the upper and lower bands. A green diamond below the price signals a potential buy opportunity when the price crosses below the lower band, while a red diamond above the price indicates a potential sell signal when crossing the upper band.
  • The Cloud Gradient: The cloud transparency and color provide insight into market extremes. A solid green cloud suggests an overbought state, while a solid red cloud indicates an oversold state. The transparency shifts based on the number of consecutive bars the price remains outside the mean.
  • Information Table: The dashboard in the top-right corner provides real-time statistics, including the current market condition (Overbought/Oversold), the number of band violations since the last mean cross, and the current gradient length.
  • Dynamic Support/Resistance: Use the upper and lower volatility bands as dynamic levels for setting take-profit or stop-loss orders, as prices statistically tend to revert toward the central mean (μ).

Details

The script models asset prices using the Ornstein-Uhlenbeck (OU) process, a mathematical framework used to describe the tendency of a variable to return to a central equilibrium over time.

The tool implements this via:

  • Exponentially Weighted Moving Average (EWMA): Unlike standard moving averages, the EWMA adapts dynamically to recent price action while maintaining a memory of historical data, serving as the "mean" in the OU process.
  • Speed of Reversion (θ): By calculating the autocorrelation of log returns, the indicator estimates how quickly an asset returns to its mean.
  • Volatility-Based Thresholds: The bands are derived from the standard deviation (σ) of the price over a user-defined period, creating a statistical "cloud" that adapts to changing market volatility.

Settings

Core Parameters

  • Decay Factor (λ): Adjusts the responsiveness of the EWMA calculation. Values closer to 1 prioritize recent data, making the mean more reactive.
  • Autocorrelation Length (θ): Determines the period used to calculate volatility and the speed of mean reversion.
  • Threshold (σ): Sets the number of standard deviations for the upper and lower bands, defining the sensitivity of overbought/oversold signals.
  • Max Gradient Length (γ): Controls the transparency calculation for the cloud fill, affecting how quickly the gradient reaches full visibility during extended deviations.

FAQ

How do I use the Mean Reversion Cloud (Ornstein-Uhlenbeck)?

Apply the indicator to your chart and monitor for price crosses outside the volatility bands. Use the diamonds as entry signals and the central mean line as a target for price reversion.

What markets is this indicator best suited for?

This tool is most effective in range-bound or mean-reverting markets where prices oscillate around a central equilibrium rather than trending strongly in one direction.

How can I access this tool?

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.