You've measured regimes, split tests by them, and written warning signs. The natural next thought is: why not add a rule that switches the strategy off in the regimes where it struggled? That's a regime filter. By the end of this lesson, you'll know how to write one so it only uses information known at the time. You'll see why it's one of the easiest rules to fit to the past. And you'll know the checks traders put it through, and other ways people handle regimes. One thing up front: nothing here says a regime filter will improve results. Whether one helps can't be known in advance.
1 of 7
What you'll learn
- Build a switch. A regime filter stops new trades in conditions you choose.
- Use only earlier data. Each filter reading must be known before the trade.
- Guard against fitting the past. You've seen the losses, and the filter rests on few spells.
- Count the cost of lag. A late switch can cost as much as it saves.
- Test it on kept-back data. Nudge the line and length, and count the spells.
Exercise
- Write a regime filter on paper for a strategy you've tested, using only data known before each trade.
- Before testing it, write the reason, the dates you'll keep back and the nudges you'll try.
- Then count how many spells it would switch for.
Quick check
1. A filter uses the label "this month was ranging", decided at the month's end, to skip trades during that month. What's wrong?
2. A test has 300 trades but only three ranging spells. What does a ranging filter really rest on?
3. A regime filter improved a backtest. What does that show on its own?
0 of 3 answered.
Finished this lesson?
Tick it off and keep your place
Read the full notes
A A rule that lets a strategy trade only in the kinds of market chosen for it, such as trending or calm, and switches it off in the rest. It can use only data known before each trade.More in the glossary switches a A written set of rules that says what to trade, when to get in and when to get out, so the same chart always gets the same decision.More in the glossary off in conditions you choose, using only data known before each trade. It's easy to Tuning a strategy’s rules so closely to one stretch of past prices that they describe that stretch’s quirks more than anything that carries on.More in the glossary, its lag can cost as much as it saves, and a better Running a strategy’s exact rules over past prices to see which trades they would have taken.More in the glossary after adding one isn't evidence on its own.
- A A rule that lets a strategy trade only in the kinds of market chosen for it, such as trending or calm, and switches it off in the rest. It can use only data known before each trade.More in the glossary is a switch on top of the rules: on, trade as written; off, no new trades. It may use only data known before the trade, such as a 60-day Perry Kaufman’s measure of how straight price moved: the distance covered divided by the total of every move along the way, from 0 to 1.More in the glossary at yesterday's close. Hindsight labels would be look-ahead bias.
- Standing aside is the same idea by hand (When to stand aside). A skipped trade scores zero, on losing days and winning days alike.
- Easy to Tuning a strategy’s rules so closely to one stretch of past prices that they describe that stretch’s quirks more than anything that carries on.More in the glossary: you've seen where the losses were; it rests on a few spells, not many trades; the line and length are free choices (Data mining and the many-tests problem); and a filter that only removes trades can always be fitted to look better on the past.
- Made-up lag cost: +11.4R unfiltered; two months late off saves 3.2R, two months late on misses 7R: 11.4 + 3.2 − 7 = +7.6R. Other numbers could go the other way.
- Checks: a reason first; unchanged on kept-back data with its own regime changes (In-sample and out-of-sample data); nudge the line and length (Nudging the settings); count the spells. Passing doesn't prove it will help. See When a filter helps and when it overfits.
- Other ways: accept the bad spells, trade smaller instead of stopping, or run strategies suited to different conditions. More: Market regimes and Overfitting.
Worked example
Made-up numbersWhat the lag costs
Made-up numbers · +3.5R a trending month, −1.6R a ranging month · the filter switches two months late
- No filter: +11.4R for the year.
- Off in June and July (ranging): saves 2 × 1.6 = 3.2R.
- Still off in August and September (trending): misses 2 × 3.5 = 7R.
- Filtered: 11.4 + 3.2 − 7 = +7.6R.
Here the lag cost more than the filter saved. Other numbers could go the other way.
Trading is risky. You can lose money. Test results are hypothetical, and past market conditions don't tell you what comes next. This lesson explains how markets and testing work. It isn't advice.