Concept

Kalman Filter

Kalman Filter is a Statistics concept. The Library holds 3 implementations, each one a working definition you can pull into Quant.

trend. adaptive hedge ratio

Top Kalman Filter indicators

3 total

What is a Kalman Filter?

A Kalman filter is a recursive estimator, introduced by Rudolf Kálmán in 1960 for control engineering, that tracks the hidden state of a noisy system one observation at a time. Applied to markets, the usual assumption is that each print is an unobserved 'true' level plus noise. Every bar the filter predicts where that level should be from a simple motion model, then blends the prediction with the new price. The blending weight, called the Kalman gain, is recomputed each step from two variances: how much the true state is allowed to wander (process noise) and how noisy observations are (measurement noise).

Traders use it as an adaptive smoother: when the settings imply prices are informative, the gain rises and the filter hugs price; when they imply noise, it flattens and rides out chop. The same recursion can estimate an evolving hedge ratio between two instruments in pairs trading, an example of adaptive parameterization done with explicit statistics. The caveat is that the output is only as good as the assumed model: the filter still lags at genuine turning points, and badly chosen noise settings produce smooth, confident-looking lines that are simply wrong.

How a Kalman filter works

The filter is a two-step loop, predict then update, run once per bar.

  1. 1Specify the model: choose the state to track (a smoothed price level, often paired with its velocity) and set the two noise variances, process and measurement. Their ratio is the filter's real tuning knob.
  2. 2Predict: project the state one bar forward with the motion model (unchanged level, or level plus velocity) and widen its uncertainty by the process noise.
  3. 3Update: when the bar arrives, compute the Kalman gain from the predicted uncertainty relative to measurement noise, then pull the prediction toward the observed price by that fraction and shrink the uncertainty.
  4. 4Repeat every bar. The output plots like a moving average whose responsiveness follows the noise settings; two-state versions also emit a velocity estimate that reads as trend slope.

How traders use it

  • As an adaptive baseline: the filtered level serves the familiar moving-average roles (slope color, crossovers, a trailing reference) with responsiveness governed by the noise model rather than a fixed length setting.
  • As a dynamic hedge ratio: modeling the regression slope between two assets as the state lets the ratio update bar by bar, replacing a fixed-window linear regression in spread construction.
  • As a velocity gauge: constant-velocity variants expose the estimated rate of change directly, which some systems use as a trend/chop classifier or a momentum input.
  • As pre-processing: filtering a noisy series before it feeds another indicator trades a little delay for fewer whipsaw flips downstream.

Kalman Filter vs related concepts

EMA: An EMA is effectively a Kalman filter frozen solid: constant gain, no uncertainty tracking. The Kalman recursion recomputes its gain every bar from the modeled variances, so its effective speed floats; in the steady state on a simple level-plus-noise model, the two converge to the same line.

KAMA: Both adapt their speed, but KAMA drives it from an efficiency ratio computed on recent price action, a heuristic. The Kalman gain comes from an explicit noise model. The difference is philosophy and tunability rather than one being reliably better.

Hodrick-Prescott Filter: The HP filter fits the whole sample at once and uses future data, so its historical values change as new bars arrive. A standard Kalman filter is causal: each estimate uses only information available at that bar, which makes it usable for live signals, not just description.

Related concepts · Regression & filtering

Concept family

Statistics

45 concepts mapped · 37 in the Library

Kalman Filter FAQ

Is a Kalman filter better than a moving average?

Different rather than better. With constant settings it collapses to an exponential average; its advantage appears when the adaptive gain genuinely reflects changing noise, which depends on how well the variances are chosen. A mis-specified filter can lag or overshoot more than a plain moving average, and no filter eliminates lag at real turning points.

Does a Kalman filter repaint?

The standard filter does not: it is causal, using only current and past observations, so printed values stay put. The related Kalman smoother runs a second, backward pass over the sample and does revise history, so tools built on smoothing rather than filtering will redraw. Check which variant an implementation uses (repaint-safe engineering).

What do process noise and measurement noise control?

Their ratio sets responsiveness. Raising process noise, or lowering measurement noise, tells the filter the true level moves a lot relative to observation noise, so the gain rises and the line tracks price closely. The opposite produces heavier smoothing and more lag. Many charting implementations fold the two into one 'smoothness' input for exactly this reason.

Build Kalman Filter your way.

Quant writes, tests, and refines it with you — then it runs on LuxAlgo charting or ports to TradingView.