OPEN-SOURCE SCRIPT
Regime Classification System [JOAT]

Regime Classification System [JOAT]
Introduction
The Regime Classification System is an advanced open-source market regime detection indicator that combines smooth range filtering, multi-timeframe trend analysis (10 timeframes), impulse detection, Chandelier Exit integration, and regime strength scoring into a comprehensive market state classification system. This indicator helps traders identify whether the market is trending, ranging, volatile, or transitioning between states, enabling them to adapt their trading strategies to current market conditions.
Unlike basic trend indicators that simply show up or down, this system classifies markets into distinct regimes (Trend Bull, Trend Bear, Volatile Bull, Volatile Bear, High Vol Range, Low Vol Range, Flat) and provides confidence metrics, regime strength scores, multi-timeframe alignment analysis, and transition warnings. The indicator is designed for traders who understand that different market conditions require different trading approaches and that regime identification is critical for consistent profitability.

Why This Indicator Exists
This indicator addresses a fundamental challenge in trading: adapting strategy to market conditions. A trend-following strategy that works in trending markets fails in ranging markets. A mean-reversion strategy that works in ranging markets fails in trending markets. By systematically classifying market regimes, this indicator enables traders to:
Each component provides different regime intelligence. Range filtering shows directional movement, trend strength shows conviction, volatility ratio shows market character, impulse detection shows momentum, MTF alignment shows multi-timeframe conviction, and Chandelier Exit provides dynamic risk management. Together, they create a comprehensive regime classification system.
Core Components Explained
1. Smooth Range Filter (from RealGains Algorithm)
The range filter uses a sophisticated smoothing algorithm to identify directional movement:
Pine Script®
The filter creates upper and lower bands based on smoothed range. When price breaks above the filter, it signals upward movement. When price breaks below, it signals downward movement. The filter adapts to volatility, widening in volatile conditions and tightening in calm conditions.
Filter direction is tracked using consecutive bar counts:
Pine Script®
Longer consecutive counts indicate stronger directional conviction.
2. Impulse Detection (SMMA and ZLEMA)
The indicator uses Smoothed Moving Average (SMMA) and Zero-Lag EMA (ZLEMA) to detect impulse moves:
Pine Script®
When impulse is detected, the market has momentum. When impulse is absent (flat), the market lacks directional conviction. This helps filter out choppy, directionless periods.
3. Trend Strength Calculation (ADX-based)
The indicator calculates trend strength using Directional Movement Index (DMI) and Average Directional Index (ADX):
Pine Script®

Trend strength ranges from 0 (no trend) to 1 (strong trend). The threshold (default: 0.6) determines when a market is classified as trending vs ranging.
4. Volatility Regime Classification
Volatility regime is determined by comparing current ATR to average ATR:
Pine Script®
Volatility ratio interpretation:
High volatility regimes require wider stops and larger profit targets. Low volatility regimes allow tighter stops and smaller targets.
5. Regime Classification Logic
The indicator combines trend strength, volatility ratio, and impulse detection to classify regimes:
Pine Script®
Regime classifications:
6. Regime Strength Scoring (0-100%)
Regime strength is calculated using four components:
Pine Script®
Regime strength interpretation:

7. Regime Transition Detection
The indicator warns when regime is likely changing:
Pine Script®
Transition warnings help traders exit positions before regime changes become obvious in price.
8. Multi-Timeframe Alignment (10 Timeframes)
The indicator analyzes regime across 10 timeframes:
Pine Script®
MTF alignment score is calculated with weighted timeframes (higher timeframes have more weight):
Pine Script®
Alignment interpretation:
9. Regime Confidence Calculation
Overall confidence combines regime strength, MTF alignment, and transition status:
Pine Script®
Confidence > 70% indicates high-quality regime suitable for aggressive trading. Confidence < 40% suggests caution or avoiding trades.
10. Chandelier Exit Integration
The indicator includes Chandelier Exit for dynamic stop-loss placement:
Pine Script®
Chandelier Exit adapts to volatility, providing wider stops in volatile regimes and tighter stops in calm regimes. The stops trail price, locking in profits as trends develop.
Visual Elements
Input Parameters
Range Filter Settings:
Regime Detection:
Chandelier Exit:
Impulse Detection:
Multi-Timeframe Table:
Colors:
All colors are fully customizable including trend bull/bear, mid trend, range, high volatility, text, transition, and excellent regime colors.
How to Use This Indicator
Step 1: Identify Current Regime
Check the regime classification (Trend Bull, Trend Bear, Volatile Bull, Volatile Bear, High Vol Range, Low Vol Range, Flat). This determines your trading approach.
Step 2: Check Regime Strength
Look at regime strength percentage. > 70% indicates high-quality regime suitable for aggressive trading. < 40% suggests caution.
Step 3: Verify MTF Alignment
Check the MTF table. Strong alignment (> 60) across multiple timeframes confirms regime conviction. Mixed alignment suggests caution.
Step 4: Monitor Regime Confidence
Overall confidence score combines strength, alignment, and transition status. > 70% confidence indicates high-quality trading conditions.
Step 5: Watch for Transition Warnings
X-cross markers warn of potential regime changes. Consider tightening stops or exiting positions when transition probability is high.
Step 6: Use Chandelier Exit for Stops
The Chandelier Exit lines provide dynamic stop-loss levels that adapt to volatility. Trail stops as trends develop.
Step 7: Adapt Strategy to Regime
Best Practices
Indicator Limitations
Technical Implementation
Built with Pine Script v6 using:
The code is fully open-source and can be modified to suit individual trading styles and preferences.
Originality Statement
This indicator is original in its comprehensive regime classification approach. While individual components (range filter, ADX, Chandelier Exit) are established concepts, this indicator is justified because:
Each component contributes unique regime intelligence: range filter shows direction, trend strength shows conviction, volatility ratio shows character, impulse shows momentum, MTF alignment shows multi-timeframe conviction, transition detection shows regime changes, and Chandelier Exit provides adaptive stops. The indicator's value lies in presenting these complementary perspectives simultaneously with quantitative regime classification and confidence scoring.
Disclaimer
This indicator is provided for educational and informational purposes only. It is not financial advice or a recommendation to buy or sell any financial instrument. Trading involves substantial risk of loss and is not suitable for all investors.
Regime classification is a tool for understanding market conditions, not a crystal ball for predicting future price movement. High regime strength, strong MTF alignment, and high confidence scores do not guarantee profitable trades. Past regime patterns do not guarantee future regime patterns. Market conditions change, and strategies that worked historically may not work in the future.
The metrics displayed are mathematical calculations based on current market data, not predictions of future price movement. Transition warnings are probabilistic, not guaranteed. Chandelier Exit stops can be hit during volatile whipsaws. Users must conduct their own analysis and risk assessment before making trading decisions.
Always use proper risk management, including stop losses and position sizing appropriate for your account size and risk tolerance. Never risk more than you can afford to lose. Consider consulting with a qualified financial advisor before making investment decisions.
The author is not responsible for any losses incurred from using this indicator. Users assume full responsibility for all trading decisions made using this tool.
-Made with passion by officialjackofalltrades
Introduction
The Regime Classification System is an advanced open-source market regime detection indicator that combines smooth range filtering, multi-timeframe trend analysis (10 timeframes), impulse detection, Chandelier Exit integration, and regime strength scoring into a comprehensive market state classification system. This indicator helps traders identify whether the market is trending, ranging, volatile, or transitioning between states, enabling them to adapt their trading strategies to current market conditions.
Unlike basic trend indicators that simply show up or down, this system classifies markets into distinct regimes (Trend Bull, Trend Bear, Volatile Bull, Volatile Bear, High Vol Range, Low Vol Range, Flat) and provides confidence metrics, regime strength scores, multi-timeframe alignment analysis, and transition warnings. The indicator is designed for traders who understand that different market conditions require different trading approaches and that regime identification is critical for consistent profitability.
Why This Indicator Exists
This indicator addresses a fundamental challenge in trading: adapting strategy to market conditions. A trend-following strategy that works in trending markets fails in ranging markets. A mean-reversion strategy that works in ranging markets fails in trending markets. By systematically classifying market regimes, this indicator enables traders to:
- Identify Current Regime: Classify market as trending, ranging, volatile, or flat with quantitative metrics
- Measure Regime Strength: Score regime quality (0-100%) based on trend clarity, volatility consistency, impulse confirmation, and duration
- Detect Regime Transitions: Warn when market is likely changing character before it becomes obvious
- Analyze Multi-Timeframe Alignment: Confirm regime across 10 timeframes (1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, Daily, Weekly)
- Calculate Regime Confidence: Provide confidence score combining regime strength, MTF alignment, and transition probability
- Integrate Dynamic Stops: Use Chandelier Exit for adaptive stop-loss placement based on volatility
Each component provides different regime intelligence. Range filtering shows directional movement, trend strength shows conviction, volatility ratio shows market character, impulse detection shows momentum, MTF alignment shows multi-timeframe conviction, and Chandelier Exit provides dynamic risk management. Together, they create a comprehensive regime classification system.
Core Components Explained
1. Smooth Range Filter (from RealGains Algorithm)
The range filter uses a sophisticated smoothing algorithm to identify directional movement:
The filter creates upper and lower bands based on smoothed range. When price breaks above the filter, it signals upward movement. When price breaks below, it signals downward movement. The filter adapts to volatility, widening in volatile conditions and tightening in calm conditions.
Filter direction is tracked using consecutive bar counts:
Longer consecutive counts indicate stronger directional conviction.
2. Impulse Detection (SMMA and ZLEMA)
The indicator uses Smoothed Moving Average (SMMA) and Zero-Lag EMA (ZLEMA) to detect impulse moves:
When impulse is detected, the market has momentum. When impulse is absent (flat), the market lacks directional conviction. This helps filter out choppy, directionless periods.
3. Trend Strength Calculation (ADX-based)
The indicator calculates trend strength using Directional Movement Index (DMI) and Average Directional Index (ADX):
Trend strength ranges from 0 (no trend) to 1 (strong trend). The threshold (default: 0.6) determines when a market is classified as trending vs ranging.
4. Volatility Regime Classification
Volatility regime is determined by comparing current ATR to average ATR:
Volatility ratio interpretation:
- volRatio > 1.5: High volatility (default threshold)
- volRatio 0.67-1.5: Normal volatility
- volRatio < 0.67: Low volatility
High volatility regimes require wider stops and larger profit targets. Low volatility regimes allow tighter stops and smaller targets.
5. Regime Classification Logic
The indicator combines trend strength, volatility ratio, and impulse detection to classify regimes:
Regime classifications:
- Trend Bull: Strong uptrend with normal volatility - trend-following strategies
- Trend Bear: Strong downtrend with normal volatility - trend-following strategies
- Volatile Bull: Uptrend with high volatility - wider stops, larger targets
- Volatile Bear: Downtrend with high volatility - wider stops, larger targets
- High Vol Range: No clear trend with high volatility - avoid or use wide ranges
- Low Vol Range: No clear trend with low volatility - mean-reversion strategies
- Flat: No impulse detected - avoid trading
6. Regime Strength Scoring (0-100%)
Regime strength is calculated using four components:
Regime strength interpretation:
- > 70%: Excellent regime - high confidence trades
- 40-70%: Good regime - moderate confidence trades
- < 40%: Weak regime - low confidence or avoid
7. Regime Transition Detection
The indicator warns when regime is likely changing:
Transition warnings help traders exit positions before regime changes become obvious in price.
8. Multi-Timeframe Alignment (10 Timeframes)
The indicator analyzes regime across 10 timeframes:
MTF alignment score is calculated with weighted timeframes (higher timeframes have more weight):
Alignment interpretation:
- > 60: Strong Bull alignment
- 30-60: Moderate Bull alignment
- -30 to 30: Mixed alignment
- -60 to -30: Moderate Bear alignment
- < -60: Strong Bear alignment
9. Regime Confidence Calculation
Overall confidence combines regime strength, MTF alignment, and transition status:
Confidence > 70% indicates high-quality regime suitable for aggressive trading. Confidence < 40% suggests caution or avoiding trades.
10. Chandelier Exit Integration
The indicator includes Chandelier Exit for dynamic stop-loss placement:
Chandelier Exit adapts to volatility, providing wider stops in volatile regimes and tighter stops in calm regimes. The stops trail price, locking in profits as trends develop.
Visual Elements
- Range Filter Line: Main line showing directional filter with color-coded regime (green = bull, red = bear, cyan = neutral)
- Target Bands: Upper and lower bands showing filter range with gradient fills
- Regime Strength Zones: Gradient fills showing regime strength intensity
- Volatility Expansion Zones: Circles marking high volatility periods
- Chandelier Exit Lines: Dynamic stop-loss lines (green for long stops, red for short stops)
- Regime Value Histogram: Histogram showing regime direction and strength (-3 to +3)
- Regime Background: Subtle background coloring based on current regime
- Regime Change Markers: Circles marking regime transitions
- Transition Warnings: X-crosses marking potential regime changes
- Regime Signals: Triangle markers for strong bull/bear regime confirmations
- MTF Table: Comprehensive table showing all 10 timeframes with trend status
- Statistics Panel: Additional metrics including regime strength, duration, alignment, confidence, and transition status
Input Parameters
Range Filter Settings:
- Sampling Period: Period for range calculation (default: 100, range: 1+)
- Range Multiplier: Multiplier for range width (default: 3.0, range: 0.1+)
Regime Detection:
- Trend Threshold: Minimum trend strength for trending classification (default: 0.6, range: 0.3-0.9)
- Volatility Threshold: Multiplier for high volatility classification (default: 1.5, range: 1.0-3.0)
- Regime Strength Period: Period for strength calculations (default: 20, range: 5-100)
- Show Regime Signals: Toggle regime confirmation markers (default: enabled)
Chandelier Exit:
- Chandelier ATR Period: Period for ATR calculation (default: 22, range: 1+)
- Chandelier ATR Multiplier: Multiplier for stop distance (default: 3.0, range: 0.1+)
- Use Close for Extremums: Use close vs high/low for calculations (default: enabled)
Impulse Detection:
- Try to Catch Flat: Enable flat regime detection (default: enabled)
Multi-Timeframe Table:
- Show MTF Table: Toggle timeframe table (default: enabled)
- Table Position: Dashboard location (Top Right/Top Left/Bottom Right/Bottom Left/Middle Right)
- Show Regime Statistics: Toggle additional statistics panel (default: enabled)
Colors:
All colors are fully customizable including trend bull/bear, mid trend, range, high volatility, text, transition, and excellent regime colors.
How to Use This Indicator
Step 1: Identify Current Regime
Check the regime classification (Trend Bull, Trend Bear, Volatile Bull, Volatile Bear, High Vol Range, Low Vol Range, Flat). This determines your trading approach.
Step 2: Check Regime Strength
Look at regime strength percentage. > 70% indicates high-quality regime suitable for aggressive trading. < 40% suggests caution.
Step 3: Verify MTF Alignment
Check the MTF table. Strong alignment (> 60) across multiple timeframes confirms regime conviction. Mixed alignment suggests caution.
Step 4: Monitor Regime Confidence
Overall confidence score combines strength, alignment, and transition status. > 70% confidence indicates high-quality trading conditions.
Step 5: Watch for Transition Warnings
X-cross markers warn of potential regime changes. Consider tightening stops or exiting positions when transition probability is high.
Step 6: Use Chandelier Exit for Stops
The Chandelier Exit lines provide dynamic stop-loss levels that adapt to volatility. Trail stops as trends develop.
Step 7: Adapt Strategy to Regime
- Trend Bull/Bear: Use trend-following strategies, ride trends, trail stops
- Volatile Bull/Bear: Use wider stops, larger targets, reduce position size
- High Vol Range: Avoid or use very wide ranges
- Low Vol Range: Use mean-reversion strategies, fade extremes
- Flat: Avoid trading, wait for impulse to return
Best Practices
- Use on 15-minute to 4-hour timeframes for optimal regime clarity
- Trade with the regime, not against it - trend-following in trending regimes, mean-reversion in ranging regimes
- Higher regime strength = higher confidence = larger position sizes
- MTF alignment is critical - don't trade against higher timeframe regimes
- Transition warnings are early signals - tighten stops or exit before regime change becomes obvious
- Chandelier Exit provides objective stop-loss levels - use them
- Regime duration matters - longer regimes are more reliable
- Confidence > 70% = aggressive trading, confidence < 40% = defensive or avoid
- Flat regimes lack directional conviction - patience is key
- Volatile regimes require wider stops and larger targets - adjust risk accordingly
Indicator Limitations
- Regime classification is based on recent data - sudden news events can invalidate regimes instantly
- Transition warnings are probabilistic, not guaranteed - regimes can persist longer than expected
- MTF alignment requires sufficient data on all timeframes - may not work on newly listed instruments
- Range filter is adaptive but can lag during rapid regime changes
- Impulse detection can produce false flat signals during consolidation within trends
- Regime strength scoring is relative to recent history - not absolute
- Chandelier Exit can be stopped out during volatile whipsaws
- The indicator identifies regimes but doesn't predict when they will end
- Works best on liquid instruments with clear trending and ranging periods
- Regime confidence is a guide, not a guarantee - high confidence regimes can still fail
Technical Implementation
Built with Pine Script v6 using:
- Smooth range filter with adaptive volatility adjustment
- SMMA and ZLEMA calculations for impulse detection
- ADX-based trend strength calculations
- ATR-based volatility regime classification
- Multi-component regime strength scoring
- Transition probability calculations
- Multi-timeframe security requests (10 timeframes)
- Weighted MTF alignment scoring
- Regime confidence calculations
- Chandelier Exit with trailing stops
- Dynamic table with 17 rows showing all timeframes and statistics
- Gradient fills and color-coded visualizations
The code is fully open-source and can be modified to suit individual trading styles and preferences.
Originality Statement
This indicator is original in its comprehensive regime classification approach. While individual components (range filter, ADX, Chandelier Exit) are established concepts, this indicator is justified because:
- It synthesizes six distinct regime analysis methodologies into a unified classification system
- Regime strength scoring combines trend clarity, volatility consistency, impulse confirmation, and duration
- Transition detection provides early warnings before regime changes become obvious
- MTF alignment analysis across 10 timeframes with weighted scoring
- Regime confidence calculation integrates strength, alignment, and transition probability
- Integration of Chandelier Exit provides regime-adaptive risk management
- Comprehensive statistics panel shows regime quality metrics in real-time
- Visual regime signals help traders identify high-quality trading conditions
Each component contributes unique regime intelligence: range filter shows direction, trend strength shows conviction, volatility ratio shows character, impulse shows momentum, MTF alignment shows multi-timeframe conviction, transition detection shows regime changes, and Chandelier Exit provides adaptive stops. The indicator's value lies in presenting these complementary perspectives simultaneously with quantitative regime classification and confidence scoring.
Disclaimer
This indicator is provided for educational and informational purposes only. It is not financial advice or a recommendation to buy or sell any financial instrument. Trading involves substantial risk of loss and is not suitable for all investors.
Regime classification is a tool for understanding market conditions, not a crystal ball for predicting future price movement. High regime strength, strong MTF alignment, and high confidence scores do not guarantee profitable trades. Past regime patterns do not guarantee future regime patterns. Market conditions change, and strategies that worked historically may not work in the future.
The metrics displayed are mathematical calculations based on current market data, not predictions of future price movement. Transition warnings are probabilistic, not guaranteed. Chandelier Exit stops can be hit during volatile whipsaws. Users must conduct their own analysis and risk assessment before making trading decisions.
Always use proper risk management, including stop losses and position sizing appropriate for your account size and risk tolerance. Never risk more than you can afford to lose. Consider consulting with a qualified financial advisor before making investment decisions.
The author is not responsible for any losses incurred from using this indicator. Users assume full responsibility for all trading decisions made using this tool.
-Made with passion by officialjackofalltrades
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.