[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: Lag In Moving Avg



PureBytes Links

Trading Reference Links


I don't know what the HP stand for, I just took the name from the following article:
http://research.mpls.frb.fed.us/research/economists/ecpproj.html
I found that many people are using the Kalman filter to smoothen data. I simply translated the Fortran source code and into VBA for
Excel.

There is e.g. a research paper on the net that shows how to predict S&P turning points using Hidden Markov Models based on Kalman
smoothed data. To me there is too much math and too little magic in all this, however I liked how narrow Kalman follows the input
data.

Still I have no clue how to trade this. I just figured that if Kalman shows a change in trend (although some periods late) this
trend change is valid. Backtesting this simple assumption, however, didn't proof so far. Especially the smoothing factor makes a big
difference.

If you want to play with this XL sheet on your own data, simply cut n' paste O,H,L,C into columns C to F (all other rows are ignored
by the routine). Then check if you can live with the mean price calculation (O+H+L+C)/4  or if you want Kalman to work on other
input like C only, or a weighted price like (2*C+H+L)/4. Finally adjust the formula range for djinHPfilter. Voila. You can now
export the data, show them in a diagram, ...

Hope this helps. If not: Just yell!

Andreas
> -----Ursprüngliche Nachricht-----
> Von: owner-metastock@xxxxxxxxxxxxx
> [mailto:owner-metastock@xxxxxxxxxxxxx]Im Auftrag von Lionel Issen
> Gesendet am: Sonntag, 11. Februar 2001 17:39
> An: metastock@xxxxxxxxxxxxx
> Betreff: Re: Lag In Moving Avg
>
> What does HP-filter mean?
>
> Can you post a few more instructions to use this for other securities?
>
> In your case does "agent-provocateur" translate as "friendly neighborhood
> agitator"? :)
>
> Thanks for your posting.
> Lionel Issen
> lissen@xxxxxxxxx
> ----- Original Message -----
> From: "Andreas Grau" <agrau@xxxxxxxxxxxxxxxxxxxx>
> To: <metastock@xxxxxxxxxxxxx>
> Sent: Sunday, February 11, 2001 1:53 AM
> Subject: AW: Lag In Moving Avg
>
>
> List:
>
> I don't know if Jeff is still using the Kalman filter for his graph. If so,
> my translation of this filter available here:
> www.agent-provocateur.de/hpfilter.xls for the VBA-Code (sorry, no graphing),
> and
> www.agent-provocateur.de/hpfilter.pdf for the original explanation
>
> The VBA-routines returns an array of data. Formula input differs therefore a
> bit from the usual Excel way:
>
> - Mark the return array to receive the resulting data
>
> - enter the formula "=djinhpfilter($H$2:$H$261;$J$1)", where in this example
> "$H$2:$H$261" is the input array and "$J$1" is the
> smoothing factor
>
> - hit Shift-Ctrl-Return.
>
> If you did it right, the formula will be surrounded by { and } and copied to
> the whole return array.
>
> One word of caution: Kalman is not averaging, but smoothing data.
> Especially, it goes both directions through the input data, with
> the result, that the last few Kalman smoothed data may change as new input
> values are added. In some respect, Kalman has to be
> treated with the same caution as the Zig-Zag-Indicator.
>
>
>
> Good luck,
>
> Andreas
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: owner-metastock@xxxxxxxxxxxxx
> > [mailto:owner-metastock@xxxxxxxxxxxxx]Im Auftrag von
> > wooglin.org@xxxxxxxxxxx
> > Gesendet am: Sonntag, 11. Februar 2001 01:17
> > An: metastock@xxxxxxxxxxxxx
> > Betreff: Re: Lag In Moving Avg
> >
> > Jeff:
> >
> > What I saw on the site was very interesting.
> >
> > Is it possible to plot this non-linear trend line in MetaStock and, if so,
> > would you share the formula? If it is not possible for MetaStock, can it
> be
> > done in Excel and, if so, would you share the code?
> >
> > Thanks.
> >
> >  And to others who responded, the input was clear and concise. A real
> > tribute to the talent that is on the list. Thanks,
> >
> > Jim Barone
> >
> > ----- Original Message -----
> > From: Jeff Haferman <haferman@xxxxxxxxxxxxxxxxxxxxxxx>
> > To: <metastock@xxxxxxxxxxxxx>
> > Sent: Saturday, February 10, 2001 4:52 PM
> > Subject: Re: Lag In Moving Avg
> >
> >
> > >
> > > Bob Webb is exactly right, and said it very well.  It's
> > > not possible to remove the lag from a moving average.
> > >
> > > It is possible to draw a non-linear trendline through
> > > a time series, and this will give you an idea of
> > > the current trend.  Such a trendline doesn't appear
> > > to the eye to have the lag associated with an MA.
> > >
> > > For example, try my "plot" page at
> > > http://www.digital-web.net/~haferman/plot.html
> > >
> > > Enter any U.S. equity symbol, wait about 10 seconds,
> > > and you'll get a plot back with a best-fit non-linear
> > > trendline.
> > >
> > > Jeff
> > >
> > >
> > > Bob Webb wrote:
> > > >
> > > >Jim,
> > > >
> > > >I think I know what you mean by the question, but when you think about
> > it,
> > > >it is not possible. A "moving average of X periods" is, by its very
> > > >definition, an average of X number of previous prices (O,H,L,C) or some
> > > >other value (e.g., see the use of m.a. in the MACD). If price (e.g.,
> > Close)
> > > >is reversing from being in an upward trend to moving lower, then it
> will
> > > >take a certain number of Closes, before the moving average of X periods
> > > >will begin to also reverse direction. Thus, a moving average is, by
> very
> > > >definition, a lagging indicator.
> > > >
> > > >There are, however, two ways (and perhaps more) to decrease (but not
> > > >remove) the lag in a moving average:
> > > >
> > > >(1) make the "X" in a "moving average of X periods" a smaller number.
> > Thus
> > > >it will take a fewer number of lower Close values to turn the moving
> > > >average around.
> > > >
> > > >(2) give greater weight to the most recent X values and lesser weight
> to
> > > >the older X values. This is accomplished by using a weighted or
> > exponential
> > > >moving average.
> > > >
> > > >The danger, however with using either of these above methods (or a
> > > >combination of both), is that you will have a greater number of
> whipsaws.
> > > >
> > > >In conclusion: a moving average is, by definition, a lagging indicator.
> > > >There are other indicators that are anticipatory, but not the m.a.
> > > >
> > > >Hope this helps.
> > > >
> > > >Bob.
> > > >
> >
>
>