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

Re: [RT] General - code question



PureBytes Links

Trading Reference Links

At 9:40 PM -0700 4/13/01, BobR wrote:

>Is there any easylanguage code that will determine how well a moving
>average represents price? Suppose for example you want to compare
>different types of averages and different lengths of averages and
>desire a numerical output for fitness of each average. How would you
>write a statistical indicator to compare the close or the (H+L)/2 to
>the moving average over a period of N bars or maxbars back?

You can start by knowing that the average will lag the price. That
will be most of the error. I would assume you want to remove that
source of error first and see what is left.

The lag of many common averages (Average, XAverage, etc.) is given by:

    Lag = (Length - 1) / 2

More complex averages such as the T3Average and the JurikMA have more
complicated lag functions.

So next you might want to calculate the root-mean-square error -
something like this:

  Avg = Average(Price, Length);
  Lag = (Length - 1) / 2;
  Error = Price[Lag] - Avg;
  SqrErr = Error * Error;
  MSqrErr = Average(SqrErr, Length2);
  if MSqrErr > 0 then RMSE = SquareRoot(MSqrErr);

or the average absolute error - something like this:

  Avg = Average(Price, Length);
  Lag = (Length - 1) / 2;
  Error = Price[Lag] - Avg;
  AbsErr = AbsValue(Error);
  MAbsErr = Average(AbsErr, Length2);

The choice will depend upon what you are trying to determine.

Bob Fulks



To unsubscribe from this group, send an email to:
realtraders-unsubscribe@xxxxxxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/