OPEN-SOURCE SCRIPT
已更新 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
版本注释
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.
版本注释
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.
版本注释
Slight bug fixImproved table
Added in optional trigger for bar color in "Danger" zones
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。