OPEN-SOURCE SCRIPT
Sample Entropy (SampEn) Regime Detector

Sample Entropy (SampEn) Regime Detector (V6)
This indicator introduces Sample Entropy (SampEn) to TradingView—a sophisticated complexity measure used in algorithmic trading and academia to quantify how predictable or chaotic price behavior is. Unlike Approximate Entropy (ApEn), SampEn eliminates self-matching bias, making it far more reliable for financial time series.
How it works:
The indicator analyzes a rolling window of price action to find repeating patterns.
Low SampEn (Green Background): Indicates high regularity. The market is in a structured phase (strong trend or clean mean-reversion). Your standard strategies (RSI, MACD, Moving Averages) are most effective here.
High SampEn (Red Background): Indicates pure randomness or "Chop." The market lacks a tradable pattern. This is where most "fake-outs" happen.
Adaptive EMA (Yellow Line): This is a dynamic moving average that adjusts its smoothing based on entropy. In predictable regimes, it tightens to track price; in chaotic regimes, it slows down to filter out noise.
How to use it:
Regime Filter: Use the background colors as a "Traffic Light." Only take trades when the background is Green (Predictable) or neutral.
Risk Management: If the SampEn Score (top right) is above 2.0, consider reducing your position size or tightening your Stop-Loss, as the market is entering a high-noise phase.
Breakout Confirmation: A sudden drop in entropy (shifting from Red to Green) often signals the start of a massive, organized move.
Key Features:
V6 Engine: Optimized for the latest Pine Script performance.
Adaptive Smoothing: EMA speed changes bar-by-bar based on market chaos.
Professional Alerts: Built-in alerts for regime changes to reduce screen fatigue.
This indicator introduces Sample Entropy (SampEn) to TradingView—a sophisticated complexity measure used in algorithmic trading and academia to quantify how predictable or chaotic price behavior is. Unlike Approximate Entropy (ApEn), SampEn eliminates self-matching bias, making it far more reliable for financial time series.
How it works:
The indicator analyzes a rolling window of price action to find repeating patterns.
Low SampEn (Green Background): Indicates high regularity. The market is in a structured phase (strong trend or clean mean-reversion). Your standard strategies (RSI, MACD, Moving Averages) are most effective here.
High SampEn (Red Background): Indicates pure randomness or "Chop." The market lacks a tradable pattern. This is where most "fake-outs" happen.
Adaptive EMA (Yellow Line): This is a dynamic moving average that adjusts its smoothing based on entropy. In predictable regimes, it tightens to track price; in chaotic regimes, it slows down to filter out noise.
How to use it:
Regime Filter: Use the background colors as a "Traffic Light." Only take trades when the background is Green (Predictable) or neutral.
Risk Management: If the SampEn Score (top right) is above 2.0, consider reducing your position size or tightening your Stop-Loss, as the market is entering a high-noise phase.
Breakout Confirmation: A sudden drop in entropy (shifting from Red to Green) often signals the start of a massive, organized move.
Key Features:
V6 Engine: Optimized for the latest Pine Script performance.
Adaptive Smoothing: EMA speed changes bar-by-bar based on market chaos.
Professional Alerts: Built-in alerts for regime changes to reduce screen fatigue.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.