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

Re:Lars Kestner K Ratio



PureBytes Links

Trading Reference Links

I used the original code posted a couldn't verify it I made a few changes based
on my understanding of KRatio, and EL I would like to have someone let me know
if this is correct I changed YProj3/4ta0+(Beta1*Count);
To YProj = (.75 * Beta0) + (Beta1*Count); and
Kratio3/4ta1/(StdErrB*SquareRoot(Obs)); To
Kratio =  (.75 * Beta1) / (StdErrB*SquareRoot(Obs));
The whole code is below.


 
 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 = (.75 * Beta0) + (Beta1*Count);
SumResidSqr = SumResidSqr + Square(Equity[Count] - YProj); end;
SigmaRegress = SquareRoot(SumResidSqr / (Obs-2));
StdErrB = (SigmaRegress) / (SquareRoot(SumXSqr));
Kratio =  (.75 * Beta1) / (StdErrB*SquareRoot(Obs));
Print("Kratio",Kratio:4:2); end;