OPEN-SOURCE SCRIPT
Bifurcation Early Warning

Bifurcation Early Warning (BEW) — Chaos Theory Regime Detection
OVERVIEW
The Bifurcation Early Warning indicator applies principles from chaos theory and complex systems research to detect when markets are approaching critical transition points — moments where the current regime is likely to break down and shift to a new state.
Unlike momentum or trend indicators that tell you what is happening, BEW tells you when something is about to change. It provides early warning of regime shifts before they occur, giving traders time to prepare for increased volatility or trend reversals.
THE SCIENCE BEHIND IT
In complex systems (weather, ecosystems, financial markets), major transitions don't happen randomly. Research has identified three universal warning signals that precede critical transitions:
1. Critical Slowing Down
As a system approaches a tipping point, it becomes "sluggish" — small perturbations take longer to decay. In markets, this manifests as rising autocorrelation in returns.
2. Variance Amplification
Short-term volatility begins expanding relative to longer-term baselines as the system destabilizes.
3. Flickering
The system oscillates between two potential states before committing to one — visible as increased crossing of mean levels.
BEW combines all three signals into a single composite score.
COMPONENTS
AR(1) Coefficient — Critical Slowing Down (Blue)
Measures lag-1 autocorrelation of returns over a rolling window.
• Rising toward 1.0: Market becoming "sticky," slow to mean-revert — transition approaching
• Low values (<0.3): Normal mean-reverting behavior, stable regime
Variance Ratio (Purple)
Compares short-term variance to long-term variance.
• Above 1.5: Short-term volatility expanding — energy building before a move
• Near 1.0: Volatility stable, no unusual pressure
Flicker Count (Yellow/Teal)
Counts state changes (crossings of the dynamic mean) within the lookback period.
• High count: Market oscillating between states — indecision before commitment
• Low count: Price firmly in one regime
INTERPRETING THE BEW SCORE
0–50 (STABLE): Normal market conditions. Existing strategies should perform as expected.
50–70 (WARNING): Elevated instability detected. Consider reducing exposure or tightening risk parameters.
70–85 (DANGER): High probability of regime change. Avoid initiating new positions; widen stops on existing ones.
85+ (CRITICAL): Bifurcation likely imminent or in progress. Expect large, potentially unpredictable moves.
HOW TO USE
As a Regime Filter
• BEW < 50: Normal trading conditions — apply your standard strategies
• BEW > 60: Elevated caution — reduce position sizes, avoid mean-reversion plays
• BEW > 80: High alert — consider staying flat or hedging existing positions
As a Preparation Signal
BEW tells you when to pay attention, not which direction. When readings elevate:
• Watch for confirmation from volume, order flow, or other directional indicators
• Prepare for breakout scenarios in either direction
• Adjust take-profit and stop-loss distances for larger moves
For Volatility Adjustment
High BEW periods correlate with larger candles. Use this to:
• Widen stops during elevated readings
• Adjust position sizing inversely to BEW score
• Set more ambitious profit targets when entering during high-BEW breakouts
Divergence Analysis
• Price making new highs/lows while BEW stays low: Trend likely to continue smoothly
• Price consolidating while BEW rises: Breakout incoming — direction uncertain but move will be significant
SETTINGS GUIDE
Core Settings
• Lookback Period: General reference period (default: 50)
• Source: Price source for calculations (default: close)
Critical Slowing Down (AR1)
• AR(1) Calculation Period: Bars used for autocorrelation (default: 100). Higher = smoother, slower.
• AR(1) Warning Threshold: Level at which AR(1) is considered elevated (default: 0.85)
Variance Growth
• Variance Short Period: Fast variance window (default: 20)
• Variance Long Period: Slow variance window (default: 100)
• Variance Ratio Threshold: Level for maximum score contribution (default: 1.5)
Regime Flickering
• Flicker Detection Period: Window for counting state changes (default: 20)
• Flicker Bandwidth: ATR multiplier for state detection — lower = more sensitive (default: 0.5)
• Flicker Count Threshold: Number of crossings for maximum score (default: 4)
TIMEFRAME RECOMMENDATIONS
• 5m–15m: Use shorter periods (AR: 30–50, Var: 10/50). Expect more noise.
• 1H: Balanced performance with default or slightly extended settings (AR: 100, Var: 20/100).
• 4H–Daily: Extend periods further (AR: 100–150, Var: 30/150). Cleaner signals, less frequent.
ALERTS
Three alert conditions are included:
• BEW Warning: Score crosses above 50
• BEW Danger: Score crosses above 70
• BEW Critical: Score crosses above 85
LIMITATIONS
• No directional bias: BEW detects instability, not direction. Combine with trend or momentum indicators.
• Not a timing tool: Elevated readings may persist for several bars before the actual move.
• Parameter sensitive: Optimal settings vary by asset and timeframe. Backtest before live use.
• Leading indicator trade-off: Early warning means some false positives are inevitable.
CREDITS
Inspired by research on early warning signals in complex systems:
• Dakos et al. (2012) — "Methods for detecting early warnings of critical transitions"
DISCLAIMER
This indicator is for educational and informational purposes only. It does not constitute financial advice. Past performance is not indicative of future results. Always conduct your own analysis and risk management. Use at your own risk.
OVERVIEW
The Bifurcation Early Warning indicator applies principles from chaos theory and complex systems research to detect when markets are approaching critical transition points — moments where the current regime is likely to break down and shift to a new state.
Unlike momentum or trend indicators that tell you what is happening, BEW tells you when something is about to change. It provides early warning of regime shifts before they occur, giving traders time to prepare for increased volatility or trend reversals.
THE SCIENCE BEHIND IT
In complex systems (weather, ecosystems, financial markets), major transitions don't happen randomly. Research has identified three universal warning signals that precede critical transitions:
1. Critical Slowing Down
As a system approaches a tipping point, it becomes "sluggish" — small perturbations take longer to decay. In markets, this manifests as rising autocorrelation in returns.
2. Variance Amplification
Short-term volatility begins expanding relative to longer-term baselines as the system destabilizes.
3. Flickering
The system oscillates between two potential states before committing to one — visible as increased crossing of mean levels.
BEW combines all three signals into a single composite score.
COMPONENTS
AR(1) Coefficient — Critical Slowing Down (Blue)
Measures lag-1 autocorrelation of returns over a rolling window.
• Rising toward 1.0: Market becoming "sticky," slow to mean-revert — transition approaching
• Low values (<0.3): Normal mean-reverting behavior, stable regime
Variance Ratio (Purple)
Compares short-term variance to long-term variance.
• Above 1.5: Short-term volatility expanding — energy building before a move
• Near 1.0: Volatility stable, no unusual pressure
Flicker Count (Yellow/Teal)
Counts state changes (crossings of the dynamic mean) within the lookback period.
• High count: Market oscillating between states — indecision before commitment
• Low count: Price firmly in one regime
INTERPRETING THE BEW SCORE
0–50 (STABLE): Normal market conditions. Existing strategies should perform as expected.
50–70 (WARNING): Elevated instability detected. Consider reducing exposure or tightening risk parameters.
70–85 (DANGER): High probability of regime change. Avoid initiating new positions; widen stops on existing ones.
85+ (CRITICAL): Bifurcation likely imminent or in progress. Expect large, potentially unpredictable moves.
HOW TO USE
As a Regime Filter
• BEW < 50: Normal trading conditions — apply your standard strategies
• BEW > 60: Elevated caution — reduce position sizes, avoid mean-reversion plays
• BEW > 80: High alert — consider staying flat or hedging existing positions
As a Preparation Signal
BEW tells you when to pay attention, not which direction. When readings elevate:
• Watch for confirmation from volume, order flow, or other directional indicators
• Prepare for breakout scenarios in either direction
• Adjust take-profit and stop-loss distances for larger moves
For Volatility Adjustment
High BEW periods correlate with larger candles. Use this to:
• Widen stops during elevated readings
• Adjust position sizing inversely to BEW score
• Set more ambitious profit targets when entering during high-BEW breakouts
Divergence Analysis
• Price making new highs/lows while BEW stays low: Trend likely to continue smoothly
• Price consolidating while BEW rises: Breakout incoming — direction uncertain but move will be significant
SETTINGS GUIDE
Core Settings
• Lookback Period: General reference period (default: 50)
• Source: Price source for calculations (default: close)
Critical Slowing Down (AR1)
• AR(1) Calculation Period: Bars used for autocorrelation (default: 100). Higher = smoother, slower.
• AR(1) Warning Threshold: Level at which AR(1) is considered elevated (default: 0.85)
Variance Growth
• Variance Short Period: Fast variance window (default: 20)
• Variance Long Period: Slow variance window (default: 100)
• Variance Ratio Threshold: Level for maximum score contribution (default: 1.5)
Regime Flickering
• Flicker Detection Period: Window for counting state changes (default: 20)
• Flicker Bandwidth: ATR multiplier for state detection — lower = more sensitive (default: 0.5)
• Flicker Count Threshold: Number of crossings for maximum score (default: 4)
TIMEFRAME RECOMMENDATIONS
• 5m–15m: Use shorter periods (AR: 30–50, Var: 10/50). Expect more noise.
• 1H: Balanced performance with default or slightly extended settings (AR: 100, Var: 20/100).
• 4H–Daily: Extend periods further (AR: 100–150, Var: 30/150). Cleaner signals, less frequent.
ALERTS
Three alert conditions are included:
• BEW Warning: Score crosses above 50
• BEW Danger: Score crosses above 70
• BEW Critical: Score crosses above 85
LIMITATIONS
• No directional bias: BEW detects instability, not direction. Combine with trend or momentum indicators.
• Not a timing tool: Elevated readings may persist for several bars before the actual move.
• Parameter sensitive: Optimal settings vary by asset and timeframe. Backtest before live use.
• Leading indicator trade-off: Early warning means some false positives are inevitable.
CREDITS
Inspired by research on early warning signals in complex systems:
• Dakos et al. (2012) — "Methods for detecting early warnings of critical transitions"
DISCLAIMER
This indicator is for educational and informational purposes only. It does not constitute financial advice. Past performance is not indicative of future results. Always conduct your own analysis and risk management. Use at your own risk.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.