Thank you Howard, re_Rowland and Mike Was trying to avoid the CBT but it looks like I gotta dive in.
BTW Howard, which of your books would best cover this level of experience? Thanks for your help again RZ ________________________________ From: Howard B <[email protected]> To: [email protected] Sent: Sat, 12 June, 2010 2:39:54 AM Subject: Re: [amibroker] Limiting Drawdown in a Backtest Hi RZ -- You can do this by creating a custom objective function. It could as simple as assigning the custom function a value of 0 whenever the parameter set results show maximum system drawdown exceeds 30%. Try this: //////////// ///////// ///////// ///////// // // LimitDrawdown. afl // // Use CustomBacktester to limit // drawdown in trading systems. // // Howard Bandy // June 2010 // OptimizerSetEngine( "cmae" ); // The custom backtest code // to penalize results that do not // meet your specifications DesiredDDLimit = 30; SetCustomBacktestPr oc( "" ); if ( Status( "action" ) == actionPortfolio ) { bo = GetBacktesterObject (); bo.backtest( ); st = bo.getperformancest ats( 0 ); MaxSysDD = abs( st.getvalue( "MaxSystemDrawdownPe rcent" ) ); NetProfPct = st.getvalue( "NetProfitPercent" ); ObFn = ( MaxSysDD < DesiredDDLimit ) * NetProfPct; bo.addcustommetric( "FilteredNetProfit", ObFn ); } // The Buy and Sell signals MA1Len = Optimize( "MA1Len", 5, 1, 100, 1 ); MA2Len = Optimize( "MA2Len", 20, 1, 100, 1 ); MA1 = EMA( C, MA1Len ); MA2 = EMA( C, MA2Len ); Buy = Cross( MA1, MA2 ); Sell = Cross( MA2, MA1 ); e = Equity(); Plot( e, "E", colorGreen, styleLine ); //////////// ////// end //////////// //////// //////////// ///////// ///////// ///////// / Thanks, Howard On Fri, Jun 11, 2010 at 6:37 AM, ics4mer <ics4...@yahoo. com.au> wrote: > > > > > > > > > > > > > > > > > >> > >> > >Hi, > >>Doing a bit of backtesting lately, and I was wondering how to limit the >>drawdown while using another metric for the objective function. > >>Lets say that I want to optimize for Net Profit, but I won't accept parameter >>sets that result in a drawdown of more than 30% > >>I know it can be done (AB does anything). > >>Could somebody give me a pointer please? >>I can't find explicit references to it in the archive, and I don't think I'm >>ready for some of the more intricate parts of the CBT. > >>TIA > >>RZ > >
