Some time ago Tomasz posted the code below (simplified) on the KB. Would
anyone know how to modify this code to save the metrics for individually
backtested tickers? Composites would be named like "UI_"+Name(). I want to
run individual backtests over a watchlist and save ticker-specific metrics
in composites. The metrics would be read/used in another trading system.

many thanks for any help you can give!
herman

// Demo trading system
Short = Cover = 0;
Buy=Cross( MACD(), Signal() );
Sell=Cross( Signal(), MACD() );

// Using the CBT to retrieve/save metrics
SetOption("UseCustomBacktestProc", True );
if( Status("action") == actionPortfolio )
{
  bo = GetBacktesterObject();
  bo.PreProcess();
  MyHistStat1 = Null;

  for(bar=0; bar < BarCount; bar++)
  {
   bo.ProcessTradeSignals( bar );
   stats = bo.GetPerformanceStats( 0 );
   MyHistStat1[ bar ] = stats.GetValue("UlcerIndex"); // any metric can be
retrieved
  }

  bo.PostProcess();
  AddToComposite( MyHistStat1, "~~~UI_HISTORICAL", "X",
atcFlagEnableInPortfolio | atcFlagDefaults );
}

PlotForeign("~~~UI_HISTORICAL", "UlcerIndex Historical", colorRed,
styleLine );

Reply via email to