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

Re: Hurst exponent code?



PureBytes Links

Trading Reference Links

At 4:18 PM -0500 4/11/01, Randy Rehler wrote:

>Any one have the code for the Hurst exponent?

Here is a version. Please let me know if you find that it is good for
anything. So far I haven't found a use for it. <g>

Bob Fulks


{ ***********************************************************************

   Function     : Hurst
	
   Last Edit    : 3/3/01

   Provided By	: Bob Fulks

   Description : Calculates the Hurst Coefficient based upon the paper
      by J. Orlin Grabbe at <http://www.aci.net/kalliste/chaos7.htm>

************************************************************************}

Inputs: Len(Numeric);
Vars: Mean(0), j(0), k(1.253314), SumSqr(0), Scale(0), MaxY(0),
   MinY(0), Rng(0);
Arrays: X[100](0), Y[100](0);

Mean = Average(C, Len);
SumSqr = 0;
for j = 0 to Len - 1 begin
   X[j] = C[j] - Mean;
   SumSqr = SumSqr + X[j] * X[j];
end;
Scale = SquareRoot(SumSqr / Len);
Y[0] = X[0];
MaxY = X[0];
MinY = X[0];
for j = 1 to Len - 1 begin
   Y[j] = Y[j - 1] + X[j];
   if Y[j] > MaxY then MaxY = Y[j];
   if Y[j] < MinY then MinY = Y[j];
end;
Rng = MaxY - MinY;
Hurst = Log(Rng/(k * Scale)) / Log(Len);