**Syntax**

public Kalman(DataSeries source, string description)
public static Kalman Series(DataSeries source)

**Parameter Description**

*source* |
The source DataSeries |

**Description**

**Kalman**
The Kalman Filter is based on the concept of optimum estimation, first introduced by Dr. R. E. Kalman in 1960. It has generally been used in terrestrial and space-based navigation and tracking systems. In general, it can be thought of as generating an optimal (in a linear, white noise, mean-square-error sense) estimate of a future position based on the current position of a target and an estimate of its velocity and acceleration and their uncertainties.

### Interpretation

Where DataSeries are involved as in trading systems the mathematics can be simplified considerably and a (nearly) zero lag filter produced very straightforwardly. For further information see:

Optimal Tracking Filters (DOC file) by John Ehlers of MESA Software. Note that Kalman filters can be applied to any DataSeries.

### Calculation

The basic pseudo computation for the Kalman Filter value at a specific bar for a DataSeries is:

ZeroLagValue_{Bar}= |
Weight_{1} * DataSeriesValue_{Bar} + Weight_{2} * (DataSeriesValue_{Bar} - DataSeriesValue_{Bar - 3}) |

ZeroLagValue_{Bar}= |
ZeroLagValue_{Bar} + Weight_{3} * ZeroLagValue_{Last} |

ZeroLagValue_{Last}= |
ZeroLagValue_{Bar} |

Save KalmanSeriesValue_{Bar}= |
ZeroLagValue_{Bar} |

return KalmanSeriesValue_{Bar} |

**Example**

This system uses the Kalman Filter as a signal line for the CMO Oscillator to time position entries

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies
{
public class KalmanDemo : WealthScript
{
protected override void Execute()
{
DataSeries Average = ( High + Low ) / 2;
DataSeries hCMO = CMO.Series( Average, 14 );
ChartPane CMOPane = CreatePane( 40, true, true );
PlotSeries( CMOPane, hCMO, Color.Blue, LineStyle.Solid, 3 );
PlotSeries( CMOPane, Kalman.Series( hCMO ), Color.Black, LineStyle.Solid, 2 );

for(int bar = 20; bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
if( CrossOver( bar, hCMO, 0 ) )
SellAtMarket( bar+1, LastPosition, "CMO 0" );
}
else
{
if( ( CMO.Value( bar-1, Average, 14 ) < -50 ) & CrossOver( bar, hCMO, Kalman.Series( hCMO ) ) )
BuyAtMarket( bar+1, "CMO Kalman" );
}
}
}
}
}