Astor, Thanks for your analysis. Did you find a sensible way to set M in the code? As you've probably noticed, the best indicators in JBT are calculating the difference between "smoother" and "rougher" moving averages. Were you able to do the same (or the equivalent) with Kalman filter?
On Wed, Feb 2, 2011 at 2:27 AM, Astor <[email protected]> wrote: > Eugene, > > Sorry it took me a while to get back to this topic. Thank you > for implementing the Kalman filter. I have tested the implementation and it > looks good. Actually, as I will explain below, Kalman filter is far more > intuitive to set up than the EMA and hugely more powerful. > > In EMA the averaging parameter K is constant and determined from the > desired period length. Usually the period length is chosen somewhat > arbitrarily, supposedly long enough to smooth out the time series noise. But > what if you do not know what the future noise levels will be? What if the > future noise levels change? When they do, the EMA may lag the fast changing > signal or not average enough a slowing one. There is very little intuition > to setting the EMA for the future unknown signal. > > > Let standard deviation of prices before the averaging be ex ante tracking > error and standard deviation of prices around the average be ex post > tracking error. In KF, the averaging parameter K = (V + Q) / (V + Q + M). > Here, V is the ex ante predicted tracking error and is computed by the > algorirthm at each time step. Q is the process noise and M is the > measurement noise and both are set by the user. The reason Q and M got their > names has to do with their origins in engineering. In reality, for our > purposes, M is the maximum ex post tracking error that you are willing to > accept from your filter. > > If you are filtering price time series (denominated in dollars) and want > your filter to give you the smoothest possible time series that is most of > the time within, for example, $0.5 (or less) of the actual observed prices, > then you set M = (0.5)^2. If the price volatility will increase, V will > increase and K in the above formula will increase to maintain the desired > tracking error and vice versa. Thus, unlike EMA, KF is adaptive to changing > volatility. > > By increasing the value of Q, the tracking error will be pushed closer to > M. > > If, instead of choosing a constant tracking M, you let M be proportional to > the ex ante tracking error, i.e. M = b*(V+Q), then K = 1/ (1+ b), where b is > proportionality constant. Then K is constant and KF reduces to EMA. As you > can see, EMA is a special case of KF, where you are willing to accept a > randomly varying tracking error. > > I hope that Kalman helps you in your strategies. > > ------------------------------ > *From:* nonlinear5 <[email protected]> > *To:* JBookTrader <[email protected]> > *Sent:* Wed, December 1, 2010 10:25:54 AM > *Subject:* [JBookTrader] Re: Status of Kalman filter? > > By experimentation, I was able to match EMA filters with the Kalman > filters: > http://groups.google.com/group/jbooktrader/web/EMAvsKalman.PNG > > In this image, > "price" is 1-second price > "emafast" is the 60-second exponential average of price > "emaslow" is the 600-second exponential average of price > "kalmanfast" is the kalman filter of price with the measurement noise > set to 1 > "kalmanslow" is the kalman filter of price with the measurement noise > set to 100 > > The good news is the EMA and Kalman filters closely match. The bad > news is that the Kalman filter is less intuitive to set up. In > particular, the error 100 works for the price, but to get comparable > smoothing for balance, the error should probably be in the single > digits. By contrast, using the EMA requires setting the period length, > and works regardless of the range of data. > > -- > You received this message because you are subscribed to the Google Groups > "JBookTrader" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to jbooktrader+ > [email protected]. > For more options, visit this group at > http://groups.google.com/group/jbooktrader?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "JBookTrader" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<jbooktrader%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/jbooktrader?hl=en. > -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en.
