Skip to main content

Market Regime Detection for Crypto Bots: Trade the Right Strategy at the Right Time

· 9 min read
VolatiCloud Team
VolatiCloud

A trend-following strategy that returns 40% annualised in a bull market can lose 25% in a sideways one. A mean-reversion bot that prints money during range-bound conditions bleeds steadily the moment the market picks a direction. The strategy isn't broken — the market regime changed, and the bot didn't notice.

Market regime detection is the discipline of identifying which type of market you're in before committing to a signal. When baked into your bot's entry logic, it acts as a filter: trend-following signals are only taken during trending conditions, mean-reversion signals only during ranging ones. The result is a bot that loses less when conditions are unfavourable and captures more when they are.

What Are Market Regimes?

Crypto markets cycle through three broad regimes:

RegimeCharacteristicsStrategies that work
Trending (bull or bear)Sustained directional moves, increasing volume, breakout from rangesEMA crossovers, momentum, breakout strategies
Ranging (sideways)Price oscillates between support and resistance, mean-reverting behaviourRSI reversals, Bollinger Band mean reversion, grid approaches
High-volatility / chaoticSharp moves in either direction, compressed/explosive BB, elevated ATRReduce position sizes, widen stops, or sit out

No single indicator perfectly identifies regime in real time, but three have a strong track record:

  • ADX (Average Directional Index) — measures trend strength regardless of direction. ADX > 25 is generally considered trending; < 20 is ranging.
  • Bollinger Band Width — the distance between upper and lower bands, normalised by the middle band. Tight bands (low width) signal a range; wide bands signal trending or high-volatility conditions.
  • ATR (Average True Range) — tracks absolute volatility per candle. Useful for scaling stop distances and as a secondary volatility filter.

Used together, these three give you a reasonable picture of which regime you're in, in real time.

The Problem with Ignoring Regime

Most backtesting errors stem from optimising a strategy against one dominant regime in the test window. If your backtest covers 2020–2021 — a predominantly trending bull market — a momentum strategy will look excellent. But the same strategy backtested from early 2022 through 2023 (a prolonged bear/range cycle) tells a different story.

A backtest that spans one regime is not a strategy validation. It's a description of past market conditions.

Walk-forward optimisation and out-of-sample testing (both covered in earlier posts) help. But they're diagnostic — they tell you the strategy is fragile after the fact. Regime detection is preventive: it stops the strategy taking signals it wasn't designed for.

Building a Regime Filter in VolatiCloud's Strategy Builder

VolatiCloud's Strategy Builder lets you compose multi-indicator logic trees without writing Python. Here's how to build a regime filter into your entry conditions.

Step 1: Add Regime Indicators

Navigate to Strategies → New (or open an existing strategy) and switch to the Indicators tab. Add the following:

  • ADX with period 14 — this is the standard "trend strength" gauge
  • Bollinger Bands with period 20, standard deviation 2.0 — the width between upper and lower bands is what you care about
  • ATR with period 14 — for volatility context and stop sizing

The Indicators tab shows each indicator's parameters inline. ADX and ATR are single-line indicators; Bollinger Bands produce three lines (upper, middle, lower). For regime detection you'll reference the upper and lower band values in your conditions.

Step 2: Build a Trend-Following Entry with a Regime Gate

Switch to the Long Entry tab (or Entry tab if you're in long-only mode). A clean regime-gated entry looks like this:

AND
├── [Regime Gate] ADX(14) > 25 ← market is trending
├── [Regime Gate] EMA(9) > EMA(21) ← trend is up
└── [Signal] RSI(14) crossed above 50 ← momentum confirmation

In the VolatiCloud logic tree, this is three leaf nodes under a single AND root. The ADX condition ensures you only take momentum entries when there's genuine directional movement. During a range, ADX stays below 25 and the gate closes — no trades.

Step 3: Build a Mean-Reversion Entry with the Inverse Gate

Create a separate strategy (or add to the same one with an OR block at the top level, advanced usage) for ranging conditions:

AND
├── [Regime Gate] ADX(14) < 20 ← market is ranging
├── [Signal] RSI(14) < 30 ← oversold in a range
└── [Signal] close > BB_lower ← not breaking below range

When ADX drops below 20, the mean-reversion conditions become active. When ADX climbs above 25, the mean-reversion strategy is suppressed.

Two strategies or one?

Running two separate bots — one trend-following, one mean-reversion — is often cleaner than combining them in one strategy. VolatiCloud's multi-bot portfolio approach lets you allocate capital between them and track their performance independently.

Step 4: Add Volatility Scaling via ATR

ATR doesn't gate entries directly, but it drives your stop-loss distance. In the General Settings panel within the Strategy Builder, set your stoploss as a fixed percentage — but tune it against the ATR context you observed in backtests.

A common rule: set the stoploss so that it's roughly 2x ATR from the entry. In a low-ATR ranging market, that might be 1.5%. In a high-ATR trending market, it might be 3.5%. Backtesting across different volatility regimes (use VolatiCloud's date range selector to isolate periods) lets you calibrate this empirically.

Backtesting Across Regimes

Running a single backtest on the full available history obscures regime-specific performance. Instead, test across three distinct windows:

PeriodCrypto market character
Jan 2020 – Nov 2021Strong bull trend (BTC: $7k → $69k)
Nov 2021 – Dec 2022Bear market / ranging (BTC: $69k → $15k)
Jan 2023 – Dec 2023Recovery / low-volatility range then trend
Jan 2024 – presentNew bull cycle, volatile

In VolatiCloud's backtesting interface, set the start date and end date for each window and run the backtest on the same strategy. Compare the profit factor and drawdown across windows. A regime-gated strategy should show consistent (if lower) performance across all windows, rather than brilliance in one and a wipeout in another.

What "consistent" looks like

You're not looking for equal returns across all regimes — a trend-following strategy should return more in trending markets. You're looking for controlled losses in the wrong regime. Negative returns in a ranging market are acceptable; a -40% drawdown is not.

Common Mistakes

Using ADX alone without direction confirmation. ADX measures trend strength — not direction. A falling market with ADX > 30 is a strong downtrend. Combine ADX with a directional filter (EMA relationship, price above/below a long-period MA) to avoid entering against the trend.

Setting ADX thresholds too tight. ADX > 25 / < 20 are starting points, not universal rules. On 15-minute BTC charts, ADX oscillates faster than on daily charts. Backtest your specific timeframe to find thresholds where the filter actually improves risk-adjusted performance.

Ignoring Bollinger Band width units. BB width is calculated as (upper - lower) / middle × 100. The absolute value depends on the asset's price level, so a "tight" threshold for BTC is not the same number as a tight threshold for a $2 altcoin. Always compute BB width as a percentage and set thresholds in those terms.

Chasing regime switches. Markets transition between regimes gradually, not instantly. A filter that triggers on a single candle flip will generate whipsaws. Use a rolling average of ADX (e.g. compare ADX(14) to its 5-period SMA) to smooth the transitions.

Regime Detection in VolatiCloud's Multi-Timeframe Mode

One powerful pattern: use a higher timeframe to detect regime, and a lower timeframe for signal entries.

Configure your bot to reference, say, the daily ADX for regime classification while executing entries on the 1-hour chart. When the daily ADX is trending (> 25), the hourly bot trades momentum signals. When the daily is ranging (< 20), it switches to RSI reversals.

VolatiCloud's multi-timeframe indicator support lets you add ADX(14, timeframe=1D) as an indicator alongside your primary timeframe's signals. The condition node simply references the daily-resolution value as a filter. This gives you regime stability at the macro level without being slow to react at the entry level.

For a detailed breakdown of multi-timeframe setups, see the multi-timeframe strategies guide.

Practical Starting Configuration

Here's a concrete starting point to take into your own backtests:

Strategy: Regime-Gated RSI Reversion
Timeframe: 1h
Pair: BTC/USDT

Indicators:
ADX(14)
RSI(14)
BB(20, 2.0) → upper, lower, middle
EMA(200)

Entry condition (AND):
ADX(14) < 22 → ranging regime
RSI(14) < 33 → oversold signal
close > EMA(200) → above long-term trend (avoid catching falling knives)
close > BB_lower → not in a breakdown

Exit:
ROI: 1.5% in 8 candles, trailing to 0.8%
Stop-loss: 2.5% (roughly 2x ATR on BTC/USDT 1h during low-volatility ranges)

Backtest this against 2022 ranging conditions and 2024 trending conditions separately. You should see it perform reasonably in ranges and do little in trends — exactly what the filter is designed for.

From Detection to Automation

Once you've validated the regime filter in backtests, deploying it in VolatiCloud is straightforward. The same Strategy Builder conditions that guided your backtest run identically in live trading. Configure your bot through the bot creation flow, assign it to an exchange and runner, and it will apply the regime gate to every candle it evaluates.

Regime gates like these are rules you define and tune by hand. If you'd rather have a model learn an adaptive policy from market data and a reward you define, VolatiCloud can also train FreqAI-native reinforcement-learning agents in the cloud — the machine-learning counterpart to the manual filters in this post.

Set up a trade alert to notify you when the regime gate flips (e.g. "ADX just crossed 25 — trending mode active") so you have visibility into when the bot's behaviour shifts without watching charts manually.


Regime detection turns a one-trick strategy into a more durable system. It doesn't eliminate drawdowns, but it caps the losses that come from trading the wrong approach in the wrong conditions — which is where most of a bot's damage is done.

If you're building a regime-filtering strategy and want to see it in action, open the VolatiCloud Strategy Builder and try configuring an ADX gate on your next entry logic tree. Backtest it across at least two distinct market periods before going live.