Appearance

Personalize your experience

Mode
Accent Color
Direction
MarketplacestrategiesRegime Switching
QuaScript

Regime Switching

Free

Switches between trend and mean-reversion logic by regime

0.0(0)
0 installs 0 0 comments
Q
159 listings

The QuaTick team's QuaScript analyses, run by the native C++ engine.

View Profile
quascriptstrategyregime
Free
Backtest this strategy Open in QuaTick IDE Edit in IDE
Version
Updated
Compatible

Live engine preview

QuaScriptQuaScript

The QuaScript engine's own output on the chart the terminal uses. Change the settings or edit the code and press Run to recompute it.

Regime Switchingengine result
Loading the engine result…
quatick-charts · QuaScript engine on synthetic 1-minute bars · drag to pan · scroll to zoom · Run executes the script on the engine (⌘/Ctrl+Enter while editing)

About

Trend-follows (EMA cross) in a trending regime and fades RSI extremes in a ranging regime; stands aside when the regime is noisy. Exits whenever the regime changes.


Settings



Measured backtests

Run by the backtest engine on public candles, 2025-11-01 to 2026-11-01, with the script's own commission and slippage, on BTCUSDT 1h (Binance) and ETHUSDT 1h (Binance). The figures per market are in the Measured backtest panel below. Past results do not predict future returns.


Backtest it yourself

Open it on the backtesting page to run it on any symbol, interval and date range, then use Monte Carlo, optimisation, walk-forward and robustness tests.

Strategy Rules

Entry Conditions

    Exit Conditions

      Measured backtest

      BTCUSDT 1h (Binance), 2025-11-01 to 2026-11-01 · backtest engine, script costs included

      Backtest this strategy

      -7.8%

      Return

      -1.00

      Sharpe

      -11.2%

      Max DD

      47.3%

      Win Rate

      131

      Trades

      MarketTradesReturnSharpeMax DDWin rateProfit factor
      BTCUSDT 1h131-7.8%-1.00-11.2%47.3%0.76
      ETHUSDT 1h135-8.0%-0.67-11.5%43.7%0.82

      Past results on historical data do not predict future returns.

      Source Code

      Edit in IDE
      quascript
      1strategy "Regime Switching" {
      2 overlay = true
      3 capital = 100000
      4 commission = 0.05
      5 sizing = percent_equity
      6 size = 60
      7}
      8/// Trend-follows (EMA cross) in a trending regime and fades RSI extremes in a ranging regime;
      9/// stands aside when the regime is noisy. Exits whenever the regime changes.
      10use "stats/filters" as flt
      11 
      12r = flt.regime(100)
      13fast = ta.ema(close, 20)
      14slow = ta.ema(close, 50)
      15rsi = ta.rsi(close, 14)
      16cross_up = ta.cross_up(fast, slow)
      17cross_dn = ta.cross_down(fast, slow)
      18rsi_up = ta.cross_up(rsi, 30)
      19rsi_dn = ta.cross_down(rsi, 70)
      20if r != r[1] and position.size != 0 { exit.close_all() }
      21if r == flt.Regime.trend {
      22 if cross_up { order.market("TL", side.long) }
      23 if cross_dn { order.market("TS", side.short) }
      24}
      25if r == flt.Regime.range and position.size == 0 {
      26 if rsi_up { order.market("RL", side.long) }
      27 if rsi_dn { order.market("RS", side.short) }
      28}
      29if r == flt.Regime.range and position.size > 0 and rsi > 55 { exit.close_all() }
      30if r == flt.Regime.range and position.size < 0 and rsi < 45 { exit.close_all() }
      31render.line(fast, "Fast", color = color.sky.400)
      32render.line(slow, "Slow", color = color.orange.400)
      33render.background(r == flt.Regime.trend ? color.translucent(color.emerald.500, 92) : r == flt.Regime.range ? color.translucent(color.sky.500, 94) : color.translucent(color.slate.500, 90))
      34 
      Read-only preview. Open in the QuaTick IDE to edit and deploy.

      Reviews

      No reviews yet. Be the first to review this listing.

      Discussion

      Sign in to join the discussion. Your posts and replies show up on your profile.