life ideas

September 3, 2007

amibroker

Filed under: Uncategorized — manoftoday @ 7:25 pm

 

add custom columns to the backtest results screen?

Thanks a bunch. I finally found the post addressing this. Here is
the code for anyone following this thread:
/********************* CUSTOM BACKTEST PROCEDURE ********************/
function FindValueAtDateTime( array, dt, Value )
{
found = -1;
for( i = 0; i < BarCount AND found == -1; i++ )
{
if( dt[ i ] == Value ) found = i – 1;

//Coded by Tomasz = i, but I want the value from the day BEFORE the signal
}
result = Null;
if( found != -1 ) result = array[ found ];
return result;
}
SetCustomBacktestProc(“”);
dt = DateTime();
if( Status(“action”) == actionPortfolio )
{
bo = GetBacktesterObject();
bo.Backtest(1); // run default backtest procedure
// iterate through closed trades and add some info
for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
{
SetForeign(trade.Symbol);
trade.AddCustomMetric(“Industry”,IndustryID(1) ); //Want to
see IndustryID by trade
trade.AddCustomMetric(“PScore”,trade.Score,0);
//Lookup actual price at trade entry
foi = Foreign( trade.Symbol, “I” );
temp = FindValueAtDateTime( foi, dt, trade.EntryDateTime );
// _TRACE( “Temp=” + temp );
trade.AddCustomMetric(“Actual OI”, temp/100 );
//Lookup Volume at trade entty
foi = Foreign( trade.Symbol, “V” );
temp = FindValueAtDateTime( foi, dt, trade.EntryDateTime );
trade.AddCustomMetric(“Volume”, temp, 0 );
}
// iterate through open trades and add same info
for( trade = bo.GetFirstOpenPos(); trade; trade =
bo.GetNextOpenPos() )
{
SetForeign(trade.Symbol);
trade.AddCustomMetric(“Industry”,IndustryID(1)); //Want to see
IndustryID by trade
trade.AddCustomMetric(“PScore”,trade.Score,0);
//Lookup actual price at trade entry
foi = Foreign( trade.Symbol, “I” );
temp = FindValueAtDateTime( foi, dt, trade.EntryDateTime );
// _TRACE( “Temp=” + temp );
trade.AddCustomMetric(“Actual OI”, temp );
//Lookup Volume at trade entty
foi = Foreign( trade.Symbol, “V” );
temp = FindValueAtDateTime( foi, dt, trade.EntryDateTime );
trade.AddCustomMetric(“Volume”, temp, 0 );
}
bo.ListTrades();
}

Source: amibroker : Message: Re: Is is possible to add custom columns to the backtest results screen?

Advertisements

1 Comment »

  1. I’ve been browsing online greater than three hours lately,
    but I never found any fascinating article like yours.
    It’s lovely value enough for me. In my opinion, if all webmasters and bloggers made excellent content
    material as you probably did, the internet will likely be a lot more helpful
    than ever before.

    Comment by www.wordpress.com site — March 5, 2016 @ 10:40 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: