Kalman Filter

Kalman Filter is a recursive algorithm invented in the 1960s to track a moving target from noisy measurements of its position and predict its future position. Applying the concept to pricing data, it is used to detect smooth trend lines within the data that represent the true value of the market before being disturbed by market noise.

Kalman Filter is typically used to forecast future price movement. Kalman Filter works in two stages:

1.  Predict current state based on last state, taking noise into account

2.  Update: takes measured values, and updates the state estimate

Kalman Filter is a more accurate smoothing/prediction algorithm than the moving average because it is adaptive: it accounts for estimation errors and tries to adjust its predictions from the information it learned in the previous stage.

Theoretically, Kalman Filter consists of measurement and transition components. The measurement component relates an unobservable price trend to the observable price variable. Referred to as the measurement noise, it is manifested as a deviation of predicted to actual price. The transition component specifies the price trend to either increase or decrease. Referred to as the process noise variance, it is manifested as the price smoothing component.

The parameter NoiseCovRatio is a ratio of measurement noise to process noise variance. Large values of NoiseCovRatio make trend smoother, but slow down reaction to the change in trend. Small values of NoiseCovRatio make noise smoothing worse, but keeps good reaction to the change in trend.

NoiseCovRatio = 10

NoiseCovRatio = 100

 

Kalman Filter parameters

Parameter

Description

Display

Opens sub-window to set parameters for KF, KFTE, and KFBE:

      Color = Line color.

      Weight = Line thickness.

      Display = Line style: line or histogram.

      ShareScale = Determines whether sharing of the vertical scales between studies is accepted. Auto = System determine whether sharing is feasible. On = Scale is shared regardless of the functions and studies displayed. Off = Scale is not shared. ShareScale must be On if study is overlaid on a study with multiple outputs.

MarkIt

Opens Specify Conditions window.

Offset

Distance in bars between the current bar and the bar to use in the calculation. A positive offset uses future bars. A negative offset uses past bars. For example:

1 = next bar

-2 = two bars back from current bar

Price

Price used to calculate study values.

Percent

Percentage to add to top line and subtract from the bottom line.

NoiseCovRatio

Ratio of measurement noise to process noise variance. Large values of NoiseCovRatio make trend smoother, but slow down reaction to the change in trend. Small values of NoiseCovRatio make noise smoothing worse, but keeps good reaction to the change in trend.