Herman,

Noticed something in your code that can cause problem.

SetOption("UseCustomBacktestProc",True);

If you happen to have left code in AA/Settings/Portfolio/Custom backtest 
procedure path with the box "Enable custom backtest procedure" unchecked, the 
above code will still use it.

SetCustomBacktestProc("");   will never use it and saves "brain damage" :)

Dave




 
  ----- Original Message ----- 
  From: Herman 
  To: Herman 
  Sent: Friday, August 28, 2009 6:37 AM
  Subject: Re[2]: [amibroker] How to Port-Backtest many WLs


    
  This code shows my attempt at running a portfolio Backtest over many 
WatchLists, and get only one BT summary per test. I added the name of the 
WatchLists to the AA report. The trading system is just dummy code to run the 
opt - please substitute your own.




  let me know if you can improve on it ;-)




  herman




  function ParamOptimize( description, defaultVal, minv, maxv, step )

         {

         return Optimize(description, Param(description,defaultVal, minv, maxv, 
step ), minv, maxv, step );

         }




  SetTradeDelays(0,0,0,0);

  PosQty = 5;

  SetOption( "MaxOpenPositions", PosQty );

  WLNum = ParamOptimize("WL#",932,0,928,1); // I use PD data

  StaticVarSet("WLNum",WLNum);

  SetOption ( "UseCustomBacktestProc", True );

  if ( Status( "action" ) == actionPortfolio )

  {

      bo = GetBacktesterObject();

      bo.PreProcess();

      for ( bar = 0; bar < BarCount; bar++ ) bo.ProcessTradeSignals( bar );

      WLNum = Nz(StaticVarGet("WLNum"));

      WLName = CategoryGetName( categoryWatchlist, WLNum );

      bo.PostProcess();

      bo.AddCustomMetric( "WL", WLName );

  }




  QWL = InWatchList( WLNum  );

  Buy = L < Ref( L, -1 ) AND QWL;

  Sell = H > Ref( H, -1 ) AND QWL;

  Short = Sell;

  Cover = Buy;

  BuyPrice= SellPrice = ShortPrice = CoverPrice = C;




  PositionSize = -100 / PosQty;

  PositionScore = Ref(MA(V*(H-L),10),-1);



















  Friday, August 28, 2009, 6:29:36 AM, you wrote:





       








        found it, it is simple using:




        InWatchList( listno ) 




        herman







        Thursday, August 27, 2009, 7:57:50 PM, you wrote:





             








              Hello,




              I would like to use the Optimizer to Backtest a Portfolio trading 
system on many (~1000) WatchLists, i.e., the Optimizer would select the WL to 
be tested by number, and the AA results table would show one summary row for 
each portfolio Backtest.




              What is the best way to do this?




              Many thanks!

              herman















             










       


  

Reply via email to