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

K_Ratio by Lars Kestner



PureBytes Links

Trading Reference Links

After going through several issues of TASC, I found an interesting and
useful tool in the March 1996 issue of Techincal Analysis of Stocks and
Commodities. Lars Kestner has created an indicator/system called the K_Ratio
that does a statistical analysis of a system through its equity curve. You
can include this system in your system(s) and check the print long for the
values it generated.

It usually ranges from +5 to -5. Any extreme positive value indicates that
the system is profitable and stable (in that the profits generated is
consistent, in dollar amounts). Any positive values around 0 indicates that
the system is marginally profitable and that the profit stream is highly
inconsistent. Any negatie values means that it is a losing system.
And if you have a system with extremely negative values, this means that the
systems vendor has ripped you off and you're up shit creek without a paddle
in a sinking boat. ;-)

Anyway, here's the code:

{System: K_Ratio}
Var: Obs(0),Count(0),SumXY(0),SumX(0),SumY(0),SumXSqr(0),Beta0(0),Beta1(0);
Var: SumResidSqr(0),SigmaRegress(0),StdErrB(0), YProj(0),KRatio(0);
Array: Equity[5000](0);

Obs=Obs+1;
Equity[obs]=NetProfit+OpenPositionProfit;
If Date=LastCalcDate then begin
 For count=1 to Obs begin
  SumXY=SumXY+(Count*Equity[Count]);
  SumX=SumX+Count;
  SumY=SumY+Equity[Count];
  SumXSqr=SumXSqr+Count*Count;
  end;
 Beta1=(SUmXY-(SumX*SumY)/Obs)/(SumXSqr-(SumX*SumX)/Obs);
 Beta0=(SumY/Obs)-Beta1*SumX/Obs;
 For Count=1 to Obs begin
  YProj=Beta0+(Beta1*Count);
  SumResidSqr=SumResidSqr+Square(Equity[Count]-YProj);
  end;
 SigmaRegress=SquareRoot(SumResidSqr/(Obs-2));
 StdErrB=SigmaRegress/SquareRoot(SumXSqr);
 Kratio=Beta1/(StdErrB*SquareRoot(Obs));
 Print("Kratio",Kratio:4:2);
 end;