Hi all!

We've had a lot of discussions about walk-forward tests here in this 
list. I'm trying to add some info to the IS and OOS equity curves 
chart. Below you'll find my first attempt.

Among other things I've added the K-Ratio for both equity curves but had 
to multiply the formula by 10000. Either the formula is incorrect or 
it's simply a matter of the correct scaling factor. I'd also like to 
add CAR - how would I compute that in AFL?

Any remarks and suggestions will be highly welcome!

Regards,

Thomas



PlotForeign("~~~ISEQUITY","In-Sample Equity", colorRed, styleLine); 
PlotForeign("~~~OSEQUITY","Out-Of-Sample Equity", colorGreen, 
styleLine); 
RelPerfI=Foreign("~~~ISEQUITY","c")/C;
RelPerfO=Foreign("~~~OSEQUITY","c")/C;
if(ParamToggle("Show Rel.Perf Equity", "No|Yes",0)) 
Plot(RelPerfI, "Rel.Perf. InSample", colorRed,styleDots|styleThick|
styleOwnScale) AND Plot(RelPerfO, "Rel.Perf. OutSample", 
colorGreen,styleDots|styleThick|styleOwnScale);

iseq=Foreign("~~~ISEQUITY", "C");
oseq=Foreign("~~~OSEQUITY", "C");
x=LastValue(Cum(1));

function FirstBarIndex(Condition)
{
     TotalBarsIndex = LastValue(BarIndex());
     a = 0;
     Counter = 0;
     for (a = 0 ;a < TotalBarsIndex; a++)
     {
       Counter = Counter+1;
       if (
           IsTrue(Condition[a])
          )
       a = TotalBarsIndex;
       }
     result = Counter-1;

     return result;
}

isfirst=FirstBarIndex(iseq);
osfirst=FirstBarIndex(oseq);

isTotalBars=x-isfirst;
osTotalBars=x-Osfirst;

isSlope = LinRegSlope(iseq,istotalbars);
osSlope = LinRegSlope(oseq,ostotalbars);

bar = BarIndex();
lastbar = bar; //LastValue( ValueWhen( islastbar, bar ) );

al = LastValue( ValueWhen( lastbar, LinRegSlope( iseq, Lastbar - isfirst 
+ 1 ) ) );
bl = LastValue( ValueWhen( lastbar, LinRegIntercept( iseq, Lastbar - 
isfirst + 1 ) ) );
isLr = al * ( BarIndex() - isfirst ) + bl;
isLr = IIf( bar >= isfirst AND bar <= lastbar , isLr, Null );

a2 = LastValue( ValueWhen( lastbar, LinRegSlope( oseq, Lastbar - osfirst 
+ 1 ) ) );
b2 = LastValue( ValueWhen( lastbar, LinRegIntercept( oseq, Lastbar - 
osfirst + 1 ) ) );
osLr = a2 * ( BarIndex() - osfirst ) + b2;
osLr = IIf( bar >= osfirst AND bar <= lastbar , osLr, Null );

if( ParamToggle("Show lin. reg.", "No|Yes", 0 ) )Plot( isLr , "Linear 
Reg", ParamColor( "ISLinReg Color",colorCycle), styleThick ) AND Plot( 
osLr , "Linear Reg", ParamColor( "OOSLinReg Color", colorCycle), 
styleThick );

//K-Ratio
iskratio=100000*isSlope/(StdErr(iseq,istotalbars)*istotalbars);
oskratio=100000*osSlope/(StdErr(oseq,ostotalbars)*ostotalbars);


Title = "{{NAME}} - {{INTERVAL}} {{DATE}} {{VALUES}}"
+"\n IS  Slope:       " + WriteVal(isSlope,1.1)+"  
K-Ratio:  "+WriteVal(iskratio)
+"\n OOS Slope:    " + WriteVal(OsSlope,1.1)+"  
K-Ratio:  "+WriteVal(oskratio);

Reply via email to