OPEN-SOURCE SCRIPT

Bitcoin Market Regime Detector [RegimeRisk]

579
█ WHAT THIS INDICATOR DOES

Most indicators answer "when should I buy or sell?" This one answers a different question: "what type of market am I in right now?"

Bitcoin Market Regime Detector classifies BTC into three market states:

BULL — Trend and momentum aligned to the upside. Trend-following
and breakout strategies have an edge here.
BEAR — Trend and momentum aligned to the downside. Shorts, hedging,
and risk reduction belong here.
RANGE — No dominant trend. Breakout strategies get chopped up.
Mean-reversion and range-bound setups work better.

The premise is simple: strategy selection should come after regime identification, not before. A moving average crossover strategy that prints money in a Bull regime will bleed you dry in a Range. A mean-reversion setup that works in Range will get steamrolled in a Bear. Knowing the regime first changes everything downstream.


█ HOW IT WORKS

The indicator combines four dimensions into a composite trend score:

1. Trend Direction — Fast/slow EMA crossover determines baseline bias
2. Trend Strength — ADX filters low-conviction environments
3. Momentum — RSI confirms buyer or seller control
4. Directional Index — DI+ vs DI- casts a final directional vote

Each dimension contributes to a score ranging from -2.5 (strong bearish) to +2.5 (strong bullish). The classification logic:

• ADX below threshold → Range (regardless of other signals)
• Strong positive score + RSI confirmation → Bull
• Strong negative score + RSI confirmation → Bear
• Conflicting or weak signals → Range

This layered approach prevents false regime calls during choppy, low-conviction periods where a single indicator would flip back and forth.


█ WHAT'S ON THE CHART

• Colour-coded bars — green (Bull), red (Bear), indigo (Range)
• Background shading — subtle regime colouring across the chart
• Regime change labels — flags appear when the regime shifts
• Info panel — current regime, duration in bars, and trend score
• Optional EMAs — toggle the underlying fast/slow EMAs on or off


█ ALERTS

Four alert conditions are built in:

• Regime → Bull
• Regime → Bear
• Regime → Range
• Any Regime Change

Set these through TradingView's alert menu to get notified on your phone or email when the market regime shifts.


█ SUGGESTED USE

Apply to BTCUSDT on the 4H or Daily timeframe. Use the regime as a filter for your existing strategy:

• In Bull: favour long entries, trend-following setups, breakout trades
• In Bear: favour short entries, hedging, reduced position sizes
• In Range: favour mean-reversion, avoid breakout strategies, tighten stops

The indicator works on other assets and timeframes, but the default parameters (21/55 EMA, 14-period ADX/RSI) are calibrated for BTC on higher timeframes. Adjust the inputs if applying to different instruments or lower timeframes.


█ INPUTS

Trend
• Fast EMA Length (default 21)
• Slow EMA Length (default 55)

Trend Strength
• ADX Length (default 14)
• ADX Range Threshold (default 20) — below this, market is classified as Range

Momentum
• RSI Length (default 14)
• RSI Bull Threshold (default 60)
• RSI Bear Threshold (default 40)

Display
• Background colour, regime labels, info panel, and EMAs can each be toggled independently


█ LIMITATIONS

This is a simplified regime classifier using indicators available natively in Pine Script. It does not have access to derivatives data (funding rates, open interest, liquidation flows) or cross-asset correlations that would improve classification accuracy, particularly for detecting volatility spikes and regime transitions. It is a trend/momentum-based classification tool — not a signal generator. Use it to inform your strategy selection, not as standalone buy/sell signals.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.