OPEN-SOURCE SCRIPT
Market Regime Detector [Trend + Volatility] - AI Trading Tech

The Market Regime Detector [Trend + Volatility] indicator classifies market conditions into four distinct regimes by analyzing Trend Strength and Volatility relative to historical averages. It is designed to help traders identify when to apply trend-following strategies versus mean-reversion strategies.
Methodology:
The script combines two standard technical indicators to determine the current state of price action:
Trend Filter (ADX): Uses the Average Directional Index to measure trend strength.
Default Threshold: 25 (Values above 25 indicate a trending market; values below indicate a ranging market).
Volatility Filter (Relative ATR): Compares the current Average True Range (ATR) to a longer-term Simple Moving Average (SMA) of the ATR.
High Volatility: Current ATR > Long-term Average.
Low Volatility: Current ATR < Long-term Average.
The 4 Regimes
The indicator visualizes these states via background colors and a dashboard status panel:
Trending / High Volatility (Green Background):
ADX is > 25 and ATR is above average. Indicates strong directional momentum with expanded range.
Trending / Low Volatility (Blue Background):
ADX is > 25 but ATR is below average. Indicates a steady trend with compressed range (often seen in drifting markets).
Ranging / High Volatility (Red Background):
ADX is < 25 but ATR is above average. Indicates a lack of direction despite wide price swings (choppy/noisy conditions).
Ranging / Low Volatility (Gray Background):
ADX is < 25 and ATR is below average. Indicates consolidation or low activity.
Inputs & Settings
ADX Smoothing: Length for the ADX calculation (Default: 14).
DI Length: Length for the Directional Movement Index (Default: 14).
Trend Threshold: The ADX level used to separate trending from ranging (Default: 25).
ATR Length: Length for the volatility calculation (Default: 14).
Vol Lookback: The lookback period for the historical average ATR (Default: 100).
Usage Notes
Real-time vs. Closing Basis: The dashboard and background update on every tick. For confirmed regime changes, it is recommended to wait for the bar close.
Dashboard: Displays the raw ADX value, Bullish/Bearish directional bias (based on DI+ vs DI-), and current volatility state.
Disclaimer: This tool is for informational purposes only and does not constitute financial advice. Always manage your risk.
Methodology:
The script combines two standard technical indicators to determine the current state of price action:
Trend Filter (ADX): Uses the Average Directional Index to measure trend strength.
Default Threshold: 25 (Values above 25 indicate a trending market; values below indicate a ranging market).
Volatility Filter (Relative ATR): Compares the current Average True Range (ATR) to a longer-term Simple Moving Average (SMA) of the ATR.
High Volatility: Current ATR > Long-term Average.
Low Volatility: Current ATR < Long-term Average.
The 4 Regimes
The indicator visualizes these states via background colors and a dashboard status panel:
Trending / High Volatility (Green Background):
ADX is > 25 and ATR is above average. Indicates strong directional momentum with expanded range.
Trending / Low Volatility (Blue Background):
ADX is > 25 but ATR is below average. Indicates a steady trend with compressed range (often seen in drifting markets).
Ranging / High Volatility (Red Background):
ADX is < 25 but ATR is above average. Indicates a lack of direction despite wide price swings (choppy/noisy conditions).
Ranging / Low Volatility (Gray Background):
ADX is < 25 and ATR is below average. Indicates consolidation or low activity.
Inputs & Settings
ADX Smoothing: Length for the ADX calculation (Default: 14).
DI Length: Length for the Directional Movement Index (Default: 14).
Trend Threshold: The ADX level used to separate trending from ranging (Default: 25).
ATR Length: Length for the volatility calculation (Default: 14).
Vol Lookback: The lookback period for the historical average ATR (Default: 100).
Usage Notes
Real-time vs. Closing Basis: The dashboard and background update on every tick. For confirmed regime changes, it is recommended to wait for the bar close.
Dashboard: Displays the raw ADX value, Bullish/Bearish directional bias (based on DI+ vs DI-), and current volatility state.
Disclaimer: This tool is for informational purposes only and does not constitute financial advice. Always manage your risk.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
Purchase our advanced, Pro indicators here: whop.com/ai-trading-tech/
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
Purchase our advanced, Pro indicators here: whop.com/ai-trading-tech/
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。