OPEN-SOURCE SCRIPT
Aggiornato Grok/Claude AI Regime Engine • Grok/Claude X Series

Grok/Claude AI Regime Engine
This is a TradingView indicator designed to identify market regimes (bullish, bearish, or neutral) and generate buy/sell signals based on multiple technical factors working together.
Core Concept
At its heart, this indicator tries to answer a simple question: "What kind of market are we in right now, and when should I consider buying or selling?"
It does this by blending several well-known technical analysis tools into a unified system. Think of it as a dashboard that synthesizes multiple indicators into clear, actionable information.
How It Determines Market Regime
The indicator creates what it calls a "Money Line" by combining two exponential moving averages (EMAs) — a fast one (default 8 periods) and a slow one (default 24 periods). These are weighted together, with the fast EMA getting 60% influence by default. This blended line serves as the primary trend reference.
Bullish regime is declared when the short EMA crosses above the long EMA, provided the RSI isn't already in overbought territory. Bearish regime kicks in when the opposite happens — short EMA crosses below long, as long as RSI isn't oversold. Neutral regime occurs when the indicator detects sideways, choppy conditions.
The neutral detection is particularly interesting. It uses two optional methods: one looks at how flat the Money Line's slope is (compared to recent volatility via ATR), and the other checks how close together the two EMAs are as a percentage of price. When the market is grinding sideways, these methods help the indicator avoid falsely calling a trend.
Signal Generation Logic
Buy and sell signals are generated using Donchian Channel breakouts as the trigger mechanism. The Donchian Channel tracks the highest high and lowest low over a lookback period (default 20 bars), using the previous bar's values to avoid repainting issues.
A buy signal fires when price touches or breaks below the lower Donchian band, suggesting a potential reversal from oversold conditions. A sell signal fires when price reaches the upper band. However, these raw breakout signals pass through several filters before being displayed:
FilterPurposeADX thresholdOnly signals when the market has sufficient trend strength (default: ADX > 25)RSI filterBuy signals require RSI to be oversold; sell signals require overbought RSICooldown periodPrevents signal spam by requiring a minimum number of bars between signalsClose confirmationOptional setting to require a candle close beyond the band, not just a wick
Additional Metrics Displayed
The indicator calculates and displays several supplementary metrics in an information panel. ADX (Average Directional Index) measures trend strength — values below 15 suggest a weak, ranging market, while above 25 indicates a strong trend. The colored dots at the bottom of the chart reflect this: white for weak, orange for moderate, blue for strong.
BBWP (Bollinger Band Width Percentile) measures current volatility relative to historical volatility over roughly a year of data. High readings suggest volatility expansion; low readings suggest compression, which often precedes significant moves.
Alerts and Notifications
The indicator generates alerts in two scenarios: when the market regime changes (bullish to bearish, etc.) and when buy/sell signals trigger. Alert messages include the ticker symbol, timeframe, current price, RSI, ADX, and other relevant context so you can quickly assess the situation without opening the chart.
Visual Customization
Users can toggle various display elements on or off, including the EMA lines, Donchian bands, shaded regime zones between the bands, and price labels at signal points. The shading between the upper and lower bands changes color based on the current regime — green for bullish, magenta for bearish, and blue for neutral — providing an at-a-glance view of market conditions over time.
Summary
This is essentially a trend-following system with mean-reversion entry signals, filtered by momentum and trend strength indicators. It's designed to help traders identify favorable market conditions and time entries while avoiding signals during choppy, directionless periods. The multiple confirmation layers aim to reduce false signals, though like any technical system, it will still produce losing trades in certain market conditions.
This is a TradingView indicator designed to identify market regimes (bullish, bearish, or neutral) and generate buy/sell signals based on multiple technical factors working together.
Core Concept
At its heart, this indicator tries to answer a simple question: "What kind of market are we in right now, and when should I consider buying or selling?"
It does this by blending several well-known technical analysis tools into a unified system. Think of it as a dashboard that synthesizes multiple indicators into clear, actionable information.
How It Determines Market Regime
The indicator creates what it calls a "Money Line" by combining two exponential moving averages (EMAs) — a fast one (default 8 periods) and a slow one (default 24 periods). These are weighted together, with the fast EMA getting 60% influence by default. This blended line serves as the primary trend reference.
Bullish regime is declared when the short EMA crosses above the long EMA, provided the RSI isn't already in overbought territory. Bearish regime kicks in when the opposite happens — short EMA crosses below long, as long as RSI isn't oversold. Neutral regime occurs when the indicator detects sideways, choppy conditions.
The neutral detection is particularly interesting. It uses two optional methods: one looks at how flat the Money Line's slope is (compared to recent volatility via ATR), and the other checks how close together the two EMAs are as a percentage of price. When the market is grinding sideways, these methods help the indicator avoid falsely calling a trend.
Signal Generation Logic
Buy and sell signals are generated using Donchian Channel breakouts as the trigger mechanism. The Donchian Channel tracks the highest high and lowest low over a lookback period (default 20 bars), using the previous bar's values to avoid repainting issues.
A buy signal fires when price touches or breaks below the lower Donchian band, suggesting a potential reversal from oversold conditions. A sell signal fires when price reaches the upper band. However, these raw breakout signals pass through several filters before being displayed:
FilterPurposeADX thresholdOnly signals when the market has sufficient trend strength (default: ADX > 25)RSI filterBuy signals require RSI to be oversold; sell signals require overbought RSICooldown periodPrevents signal spam by requiring a minimum number of bars between signalsClose confirmationOptional setting to require a candle close beyond the band, not just a wick
Additional Metrics Displayed
The indicator calculates and displays several supplementary metrics in an information panel. ADX (Average Directional Index) measures trend strength — values below 15 suggest a weak, ranging market, while above 25 indicates a strong trend. The colored dots at the bottom of the chart reflect this: white for weak, orange for moderate, blue for strong.
BBWP (Bollinger Band Width Percentile) measures current volatility relative to historical volatility over roughly a year of data. High readings suggest volatility expansion; low readings suggest compression, which often precedes significant moves.
Alerts and Notifications
The indicator generates alerts in two scenarios: when the market regime changes (bullish to bearish, etc.) and when buy/sell signals trigger. Alert messages include the ticker symbol, timeframe, current price, RSI, ADX, and other relevant context so you can quickly assess the situation without opening the chart.
Visual Customization
Users can toggle various display elements on or off, including the EMA lines, Donchian bands, shaded regime zones between the bands, and price labels at signal points. The shading between the upper and lower bands changes color based on the current regime — green for bullish, magenta for bearish, and blue for neutral — providing an at-a-glance view of market conditions over time.
Summary
This is essentially a trend-following system with mean-reversion entry signals, filtered by momentum and trend strength indicators. It's designed to help traders identify favorable market conditions and time entries while avoiding signals during choppy, directionless periods. The multiple confirmation layers aim to reduce false signals, though like any technical system, it will still produce losing trades in certain market conditions.
Note di rilascio
Bug fix Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.