OPEN-SOURCE SCRIPT
Aktualisiert Mean Reversion Indicator

Mean Reversion Indicator
The "Mean Reversion Indicator" combines the Augmented Dickey-Fuller (ADF) test and the Hurst Exponent to identify potential mean reversion points in a time series.
Key Features:
Augmented Dickey-Fuller (ADF) Test: This test helps determine if a time series is mean-reverting by comparing the test statistic against critical values at different confidence levels (90%, 95%, 99%).
Hurst Exponent Calculation: The Hurst exponent is used to distinguish between trending, mean-reverting, or random walk behaviors of the time series.
Standard Deviation Sampling: The script calculates standard deviations over different sampling periods to assess volatility.
Visual Representation:
The green color indicates the time series is mean-reverting.
The purple color shows a trending or random walk behavior.
A zero line is plotted for easy reference.
Bar colors change according to the mean reversion state.
How to Use:
Apply the indicator to your preferred chart.
Configure the settings to match your trading strategy.
Observe the color changes and zero line to make informed decisions about potential mean reversion points.
This indicator is a powerful tool for traders looking to exploit mean reversion strategies by combining statistical tests and advanced mathematical calculations.
Credits to george_608 for helping me with this indicator
The "Mean Reversion Indicator" combines the Augmented Dickey-Fuller (ADF) test and the Hurst Exponent to identify potential mean reversion points in a time series.
Key Features:
Augmented Dickey-Fuller (ADF) Test: This test helps determine if a time series is mean-reverting by comparing the test statistic against critical values at different confidence levels (90%, 95%, 99%).
Hurst Exponent Calculation: The Hurst exponent is used to distinguish between trending, mean-reverting, or random walk behaviors of the time series.
Standard Deviation Sampling: The script calculates standard deviations over different sampling periods to assess volatility.
Visual Representation:
The green color indicates the time series is mean-reverting.
The purple color shows a trending or random walk behavior.
A zero line is plotted for easy reference.
Bar colors change according to the mean reversion state.
How to Use:
Apply the indicator to your preferred chart.
Configure the settings to match your trading strategy.
Observe the color changes and zero line to make informed decisions about potential mean reversion points.
This indicator is a powerful tool for traders looking to exploit mean reversion strategies by combining statistical tests and advanced mathematical calculations.
Credits to george_608 for helping me with this indicator
Versionshinweise
Enhanced Calculation Method:Introduced a combined approach using Hull Moving Average (HMA) and Exponential Moving Average (EMA) for a smoother final value calculation.
Value Clamping:
Added clamping for the final value to ensure it stays within the range of -1 to 1, improving stability and interpretability of the indicator.
Market State Indicator:
Included a marketState variable to easily identify whether the market is in a "Trending" or "Reverting" state based on the final value.
Visualization Enhancements:
Updated plot colors: The final value is now plotted with color.fuchsia for negative values and color.rgb(0, 234, 255, 0) for positive values.
Added a table displaying the market state and the final value for better clarity and quick reference.
Versionshinweise
Improved Calculation Methods:- Updated deviation calculations using ta.dev for more accurate deviation measures.
- Enhanced Hurst exponent estimation using bar_index for better trend/reversion detection.
Augmented Dickey-Fuller (ADF) Test:
Integrated ADF test to determine mean reversion properties with dynamically set thresholds.
Directional Movement Index (DMI):
Incorporated DMI to refine market state determination.
Enhanced Final Calculation:
- Combined EMA and HMA values for a more balanced final trend/reversion indication.
- Clamped final HMA values between -1 and 1 for stability.
Market State Indicator:
Added a detailed market state indicator to differentiate between "Trending", "Ranging", and "Peak/Danger" states.
Visualization Enhancements:
- Updated plot colors: Used color.fuchsia for negative values and color.rgb(0, 234, 255, 0) for positive values.
- Enhanced background color to indicate dangerous market peaks.
- Added horizontal lines at 1, 0, and -1 for clear reference points.
- Updated table to display market state and the final value with improved text alignment and color coding.
Versionshinweise
Slight bug fixImproved table
Added in optional trigger for bar color in "Danger" zones
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.