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

RE: Function Help



PureBytes Links

Trading Reference Links


> -----Original Message-----
> From: Trey Johnson [mailto:dickjohnson3@xxxxxxxxxxxxxx]
> Sent: Tuesday, January 28, 2003 9:28 AM
> To: omega-list@xxxxxxxxxx
> Subject: Function Help
>
>
> I'm trying to create a function based upon a paper I read by Cynthia Kase.
> This is my first attempt at using a loop. The idea is to find the highest
> value5, which is the KSDIu, over a range of cycle lengths. I found a
> function in the archives and modified it to the following. My question is,
> does this function return the highest value for value5, which
> becomes KSDIu?
> The original function is below it.
>
> 		vars: mlval(0);
> mlval = 0;
>
> for value99 = 5 to 70 begin
>    value5 = (high - low[value99])/(StdDev(log(C[1]/C),9)*SquareRoot(252));
>    if value5> mlval then mlval = value5;
> end;
>
> KSDIu = mlval;

Looks okay, but note that (StdDev(log(C[1]/C),9)*SquareRoot(252)) is
invariant throughout the loop, and it takes 9 iterations each time to
calculate StdDev(). You can also use MAXLIST to shorten the code a bit.
Rewriting:

  vars: mlval(0);
  for value99 = 5 t 70 begin
    mlval = maxlist(mlval, high - low[value99]);
  end;
  mlval = mlval / (StdDev(log(C[1]/C),9)*SquareRoot(252));

The 5, 77, and 9 values above look quite arbitrary. You might want to make
some/all of them input parameters to the function. it seemed strange to skip
the first 4 bars as well (ie, starting value99 at 5).