Thanks to everyone who replied, you have been a big help and I now have it working. The problem was that the custom metric must be defined AFTER calling the CBT.
The code below works but is still a messy solution as I want to vary the number of columns from application to application. With each change I now have to edit two programs. I was hoping for a simpler general solution to add Columns to the regular Backtester report.
have a great day,
Herman
SetOption ( "UseCustomBacktestProc", True );
if ( Status( "action" ) == actionPortfolio )
{
bo = GetBacktesterObject();
bo.PreProcess();
for ( bar = 0; bar < BarCount; bar++ ) bo.ProcessTradeSignals( bar );
bo.PostProcess();
bo.AddCustomMetric( "Close", StaticVarGet( "Close" ) );
}
StaticVarSet( "Close", LastValue( Foreign( Name(), "C" ) ) );
Short = Cover = 0;
Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Tuesday, November 4, 2008, 11:46:52 PM, you wrote:
> Herman,
> As Mike mentioned, the price arrays are not available in the custom
> backtester. One of the challenges of using the CBT is how to get data
> into it. There are multiple ways to make the data available:
> * Foreign
> * PositionScore
> * PositionSize
> * StaticVar
> The PositionScore and PositionSize arrays are accessed differently
> in the CBT. They are available at each bar as properties of the
> signal object. For example:
> lastBar = BarCount-1;
> sig = bo.GetFirstSignal(lastBar);
> ticker = sig.Symbol;
> number1 = sig.PosSize; // PositionSize at this bar
> number2 = sig.PosScore; // PositionScore at this bar
> I have not tried using StaticVars in the CBT, but I expect it will
> work for your purpose, since I believe you do not need an array.
> Hope this helps,
> Steve
> ------------------------------------
> **** IMPORTANT ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
> *********************
> TO GET TECHNICAL 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/
|