Define the state and what counts as noise
Use the random-walk model x[t] = x[t−1] + w[t] and observation model z[t] = x[t] + v[t]. Here x is an unobserved price level and z is the observed close. Assume independent, zero-mean process noise w and measurement noise v, with variances Q and R. These are modeling assumptions about a latent level; R does not mean that the exchange reported the wrong price.
- The state has no velocity, acceleration or trend term. A two-state price-and-velocity filter is a different model, even if both scripts are called a Kalman filter indicator.
- Prices can jump and their statistical behavior can change. A small P is an internal model quantity, not proof of small future trading losses or a calibrated confidence interval.
- If prices are multiplied by 10, multiply Q, R and initial P by 100 to preserve the same gain path. Changing chart timeframe also changes the meaning of a per-bar Q.
| Symbol | Meaning in this page | Units |
|---|---|---|
| x | Estimated latent price level after the observation | Price |
| z | Observed close, or a stated synthetic observation | Price |
| Q | Variance added by the random-walk state transition per chart bar | Price squared |
| R | Assumed variance of observation noise around the latent level | Price squared |
| P | Estimated state-error variance under the model | Price squared |
| K | Weight applied to the observation residual | Unitless |