r/algotrading • • 1d ago

Strategy Fast switching between MR/Trend

Alright so I have a strategy that works well in MR and also the inverse works well on trending. I'm working on a mode where it switches between them.

Ideas so far

Vol regime

Adx

Slope

Ultimately it's a regime detection problem but the ideal version would be responsive enough to catch the macro regime flips reliably

Since it may not need to catch low tf regime changes it should be relatively simple

The vol regime I've used before looks to be a little too restrictive when scaled up to the macro tf

What have you used to detect macro regime to flip between MR and trend followers?

Any ideas are appreciated

4 Upvotes

15 comments sorted by

3

u/tepid_liquidation 1d ago

ADX with a longer lookback can work but it lags at the exact moment you need it most, right when the flip happens. I been experimenting with comparing short and long term realized vol ratios, like 10 period vs 50 period, gives you a smoother signal than raw vol regime without choking the entry

Slope on a smoothed price series is underrated for this, catches the middle of the move instead of the top or bottom. Maybe combine slope direction with ADX above some threshold as confirmation so you dont switch modes on noise

What macro timeframe you working with, daily or higher

1

u/trunksta 1d ago

Daily is probably plenty for this but may go higher if needed. Shorter if I find a better fit for small regimes but I'm happy with macro

I considered mama slope but I haven't really tested anything yet. I'm trying to keep this data clean until I have a solid theory to test

The vol ratios is an interesting idea , I've used short to long atr in the past which worked well for some strategies so could definitely work

I haven't done much with adx I'll try it again

Also considered using the flip as a size down signal rather than binary gate to reduce the damage of noisy flips

Thanks, solid ideas here

2

u/uninterestedjenny5 19h ago

I'd test a neutral state where you simply trade smaller instead of forcing an instant switch between mean reversion and trend. Those transitions are where a lot of systems get chopped up. When I use Moon I still have to be selective about direction and sometimes the useful signal is that conditions aren't clean enough to push it.

1

u/Embarrassed-Bank2835 1d ago

I’d probably avoid trying to solve it with one indicator.

For macro regime, I’d look at a combination of realized volatility, trend persistence, distance from a longer-term mean, and how often breakouts actually hold versus revert. ADX/slope can help, but they tend to lag right when the regime is changing.

One thing I’ve found useful is thinking in probabilities instead of a hard binary flip. If several conditions start lining up for trend, gradually favor the trend model more instead of instantly switching 100%.

Also be careful optimizing the detector on the same data as the two strategies. That’s where it’s really easy to build a perfect historical switch that falls apart live.

The regime filter doesn’t need to call every turn. It just needs to keep each strategy out of the environments where it gets hurt the most.

1

u/CandyInevitable3512 11h ago

good cleanup… and on the point about over‑optimisation: it’s easy to kid yourself if you tweak the same thresholds you use to evaluate the switch on the same run. walk‑forward split or a separate out‑of‑sample holdout for the detector will expose that bias. another quick guard is to run the detector on the previous day’s close only, so the switch decision doesn’t “peek” at intraday moves—keeps the backtest honest.

1

u/Imaginary-Olive8867 1d ago

Since you're keeping the data clean until you have a theory, one test I'd run before picking ADX vs slope vs vol ratio: bound the upside with a perfect-foresight switch first.

Label each day as MR or trend in hindsight (e.g. whichever of the two sub-strategies made more over the next N days), switch on that label, and compare against:

  • MR alone
  • trend alone
  • a dumb 50/50 always-on blend

If even the oracle switch barely beats the blend, no real-time detector will save it, and you've spent zero out-of-sample data finding that out. If the oracle is much better, you now know how much edge a detector can capture at most, and every candidate (ADX, slope, short/long ATR ratio) gets scored as "% of oracle captured" instead of raw PnL.

A few things that bit us doing similar daily-filter gates:

  • Use the closed daily bar only. Computing the regime on the current day's bar while trading intraday leaks the close into the decision and looks great in backtest.
  • Add hysteresis or a minimum hold (e.g. regime must persist 3–5 days, or separate enter/exit thresholds). Without it, the flips cluster exactly at the transitions where both sub-strategies are worst, and you pay the whipsaw twice.
  • Count the detector's parameters as trials. Lookback × threshold × hold length adds up fast. A switch tuned on the same data as the two strategies will look better than it is.
  • Check that "inverse works on trend" isn't the same edge flipped. If MR and trend are mirror images of one signal, the switch is really a bet on the detector alone, so the oracle test above matters even more.

The short/long ATR ratio is a reasonable first candidate: few parameters, no direction, and it reacts faster than ADX.

1

u/ATAalgotradealertATA 16h ago

A couple of regime measures that tend to react faster than ADX:

Kaufman's efficiency ratio: net change over N bars divided by the sum of the absolute bar-to-bar changes. Near 1 means price is moving cleanly in one direction, near 0 means it's chopping. It's cheap to compute, and on daily data a 20–40 bar lookback flips noticeably sooner than a long ADX.

Variance ratio or a rolling Hurst estimate: both test whether returns are trending (positively autocorrelated) or mean-reverting. They're noisier, but they ask the question you actually care about directly instead of going through volatility.

Whatever you pick, add hysteresis: switch to trend above one threshold and back to MR only below a lower one, or require it to hold for a few bars. Most of the pain at the flip comes from the filter bouncing back and forth around a single cutoff, not from the lag itself. It's also worth checking whether the inverse strategy needs the same lookback as the filter, since a mismatch there can look like regime error.

1

u/Additional-Guard-865 7h ago

One thing I'd watch with a switching mode is how often it actually flips, because the switching itself can eat the edge before the regime filter even matters.

Not regime switching exactly, but I hit the same problem with rebalancing on a crypto trend system. The live version re-checked every hour and traded whenever a position drifted. Simulated with 0.35% per side for fees and slippage, that was about 3,500 trades a year and slightly negative returns (−0.4% a year, 2022 onward). Changing it to check once a day and only act when the weight drifted more than 20% from target dropped it to about 215 trades a year and about +4% a year. I reran it with zero costs and the banded version was still ahead, but roughly two-thirds of the improvement was just fees.

For your MR/trend switch, the same idea would be a dead zone: the regime signal has to move clearly past the threshold before you flip, and maybe only re-evaluate once a day or once a week. Then count switches per year in the backtest next to the return. If it's flipping a lot near the boundary, that's probably where the chop losses are. The neutral, smaller-size state someone mentioned is basically the same fix.

Small side note on the MR half: I just tested the time stop on a daily dip-buying strategy, and holding up to 8 days instead of 5 was better in both halves of 2012–2026. A short time stop can make MR look worse than it is in a choppy regime. Backtest and paper only, not advice.

1

u/mehatebananas 5h ago

You might have better luck just picking one or the other and then instead of developing a switch for trend vs MR develop a switch that sizes down when conditions aren't alligned with you chosen approach.

For a switch, think about this more as a slider based on a combination of factors that tend to independently correlate to the market condition you're trying to capture. Grade each factor individually and then combine the scores to determine if that combined score is over your predefined threshold. This can help smooth the activation of that switch/slider so that it isn't just a single indicator giving you an abrupt on/off signal. What you're looking for is called a "market state machine"

-1

u/QuanTradin 1d ago

the switch is where these die. each half backtests fine alone, then the regime filter flips a bar or two late at every turn and you eat the worst trades of both sides. I'd score the switcher by itself against a hindsight label first, just to see how late it really is.

1

u/trunksta 1d ago

Yeah you may be right. so far on in sample nothing beats single mode. Might have to accept that it is what it is. Works decent on some instruments in one mode or the other though so it's not a total fail

0

u/QuanTradin 1d ago

that's not a fail at all. one mode per instrument that holds up out of sample beats a switcher that only looks smart in sample, and most switchers I've seen were just fitting the regime labels after the fact.