The same Kalman filter that powers mean-reversion strategies can be reconfigured to estimate trend instead — a smooth, adaptive estimate of the underlying direction of price, with much less lag than moving averages and no fixed lookback window.
The Trend State Model
For trend-following, the hidden state has two components: the current level L(t) and the current slope (trend) T(t). The model says:
This is a "local linear trend" model. The level evolves by adding the slope each bar plus some noise; the slope itself drifts slowly. The price is the level plus observation noise.
The filter's output is two values per bar: an estimate of the current level (smoothed price) and an estimate of the current slope (smoothed trend). The slope is the trading signal — positive slope means the trend is up, negative means down.
A simple MA computes the same average regardless of whether the recent price action is consistent with the trend or contradicts it. Kalman trend weights observations by how surprising they are. A bar that fits the existing trend confirms it cheaply; a bar that contradicts the trend triggers a faster update. The result is a smoother, more responsive trend estimate.
The Q Parameters
The local linear trend model has two process-noise parameters:
- Q_L (level noise): how much the level can jump unexpectedly per bar. Higher Q_L → level tracks noisy price action; lower → level is smooth.
- Q_T (trend noise): how fast the trend can change per bar. Higher Q_T → trend can pivot quickly; lower → trend is persistent.
The classic configuration: small Q_L (trust the trend, smooth out level wiggles) and very small Q_T (trends are persistent, don't flip). When markets are choppy, both should be larger to allow the filter to adapt; when markets are trending cleanly, both should be smaller.
Why It's in the Stochastic Methods Module, Not Crossover
Kalman trend lives under SC001STCB rather than the basic crossover modules because it is a statistical trend estimator with explicit assumptions and parameter inference, not a heuristic indicator. The output is a probabilistically-motivated estimate of the current trend, with an associated uncertainty (the filter's posterior variance). This makes it usable in formal risk-management — for example, sizing positions in proportion to trend-confidence.
Signal Generation
Two natural signals from a Kalman trend filter:
- Slope sign change. Long when filter slope is positive, short when negative. A slow, durable signal.
- Slope above/below threshold. Long when slope > +T, short when slope < −T. Filters out near-zero slopes that produce whipsaw.
Both can be combined with a Z-score on the residual (price − level) for a hybrid signal: only enter when the trend is clearly positive AND the price is not currently far above the level (suggesting it's an entry, not a chase).
Q and R Tuning
The grid search in SC001STCB covers (Q_L, Q_T) jointly. The robustness surface tends to show:
- A "trend-following plateau" at low Q_L and very low Q_T — strategies that ride durable trends.
- A "noise-tracking plateau" at high Q values — strategies that essentially follow price (no edge).
- Cliff edges between the two — sensitive parameter ranges.
The actionable cell is in the trend-following plateau, away from cliff edges. As always, the single best cell is overfit; pick somewhere in the middle of the plateau and walk-forward.
Strengths and Failure Modes
- Strength: smooth trend estimate without arbitrary lookback choices. Adapts naturally as conditions change.
- Strength: outputs uncertainty, which can drive sizing.
- Failure: in choppy markets with no real trend, the filter still outputs a slope. That slope flips frequently, generating whipsaw.
- Failure: abrupt regime changes (gap moves, volatility spikes) take many bars to wash out of the state estimate.
The Bottom Line
Kalman trend is the disciplined cousin of moving-average crossovers — same idea (smooth the trend), more rigorous machinery, better behavior in regime changes, and quantified uncertainty. Use it when you want a trend signal you can defend statistically; use a simple MA when speed and transparency matter more than rigor.
Further Reading
Foundational papers
- Kalman, R. E. (1960). A New Approach to Linear Filtering and Prediction Problems. Journal of Basic Engineering, 82(1), 35–45.
Textbook references
- Harvey, A. C. (1990). Forecasting, Structural Time Series Models and the Kalman Filter. Cambridge University Press.
- Hamilton, J. D. (1994). Time Series Analysis. Princeton University Press.
Related QuanterLab articles
Try it in QuanterLab
In SC001STCB run the Kalman Trend method on a trending name. Compare the slope estimate to a 50-period EMA — the Kalman slope responds to regime changes faster but is noisier; the trade-off between Q_L and Q_T tunes that responsiveness.