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

Re: [amibroker] IS and OOS equity curves revisited



PureBytes Links

Trading Reference Links

Okay - the solution for my question how to calculate CAR is rather easy:

//CAR (assuming 252 trading days per year)
InitialEquity = GetOption("InitialEquity"); 
isCAR=100*((LastValue(iseq)/InitialEquity)^(1/(isTotalBars/252)) -1);
osCAR=100*((LastValue(oseq)/InitialEquity)^(1/(osTotalBars/252)) -1);

I'm still interested in other ideas/suggestions to improve the code.

Regards,

Thomas



> 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);
>
> ------------------------------------
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> For other support material please check also:
> http://www.amibroker.com/support.html
> Yahoo! Groups Links
>
>
>


------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/