A toy trend filter you can actually implement
Most “quant” writing fails because it’s either:
- too academic to run, or
- too hand-wavy to learn from.
A better approach is a mini-lab: one small strategy idea, plus the ugly constraints that decide whether it survives.
Here’s a toy trend filter you can implement in an afternoon.
The idea (one line)
Trade SPY long only when price is above a long moving average and volatility isn’t exploding.
- Trend proxy: 200-day SMA
- Volatility proxy: 20-day ATR as % of price
Rule:
- If close > SMA200 and ATR20/close < 3%, you’re “allowed” to be long.
- Otherwise you’re in cash.
This isn’t alpha. It’s a risk posture.
Why it’s worth testing
Trend filters often don’t increase raw returns. They reduce large drawdowns—which can be the difference between sticking with a system and abandoning it.
Minimal implementation details
Data:
- daily OHLCV for SPY (or any liquid index proxy)
Indicators:
- SMA200(t)
- ATR20(t)
Signals:
- allowed(t) = close(t) > SMA200(t) AND ATR20(t)/close(t) < 0.03
Execution:
- trade at next open (simple)
The three constraints that matter
1) Lookahead bias
You must use indicators computed only from past data. No same-day close → same-day execution.
2) Transaction costs
Even “low turnover” strategies can die from costs if you flip too often in choppy regimes. Measure turnover explicitly.
3) Regime dependence
This filter tends to underperform in:
- sideways markets
- fast V-shaped recoveries
So the question isn’t “does it work?” It’s “what pain are you buying?”
What a good backtest report looks like
If you test this, don’t show me just CAGR. Show:
- max drawdown
- time-to-recover
- number of trades per year
- worst 3 trades
- performance by decade/regime
If your report can’t answer those, it’s not research.
The takeaway
Mini-labs teach faster because they’re constrained.
You can always add complexity later. Start with something you can run, understand, and critique.