Ken,
Sorting and ranking is part of portfolio backtest. You can use
this process not only to do actual backtest
but also to output ranking/sorting results.
All you need is to assign your score to
PositionScore variable.
Then, run backtest. All your signals will be ranked and sorted
according to absolute value of position score.
The code below shows how. It also generates "myoutput.txt"
Comma Separated Values (CSV) file with Symbol, Score
lines. Lines are in chronological order, within same date/time
the lines are sorted according to absolute value of score.
It also outputs the same into DebugView.
Buy=1; Sell=0; SetBacktestMode( backtestRegularRaw );
PositionScore = 100 -
RSI(); // anything you like (will be sorted/ranked according to absolute
value of pos score)
SetCustomBacktestProc("");
OutputFileName =
"myoutput.txt";
if( Status("action" )
== actionPortfolio ) { bo = GetBacktesterObject();
bo.PreProcess();
dt = DateTime();
fh =
fopen( OutputFileName,
"w" );
fputs(
"Symbol, Score\n", fh );
for( i = 0; i
< BarCount; i++ ) { strdt = DateTimeToStr( dt[ i ] );
Line = "\nDate : " + strdt + "\n"; _TRACE( Line ); fputs( Line, fh );
for( sig
= bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i) ) {
Line = sig.Symbol + "," + sig.PosScore + "\n";
_TRACE( Line ); fputs( Line, fh ); }
bo.ProcessTradeSignals( i ); }
fclose( fh );
bo.PostProcess(); }
Best regards, Tomasz
Janeczko amibroker.com
----- Original Message -----
Sent: Friday, May 09, 2008 7:38 PM
Subject: [amibroker] Greybeard Topic -
Sorting and Ranking Arrays
It has been fun to
search the yahoo archives back to 2002 and see names of a lot of the original
folks who got on the Amibroker bandwagon back in the early days, many of whom
are no longer around (at least not posting like they used to). Boy, how
the program has evolved and improved over these many
years.
I was looking back
there in the archives for messages on the Osaka Plugin (which is still on my
hard drive since 2002 but which I have never used). Maybe
now......
I have a need to
take a watchlist and position rank several columns of calculations and
determine the postion rank of the ticker for that calculation; then do the
same for another column (calculation), get the position rank for that
additional column, and then combine the position ranking numbers for the
columns for each ticker, sort of to get a Master ranking
parameter.
My question is:
what new features in AB might help accomplish this? Surely the Osaka
Plugin (2002 vintage) is not the only way to do what I want. I have not
really studied nor used Static and Dynamic variables---is this the set of
commands that I would use with looping to get position ranks of a
watchlist?
I did find and
just tested some code from the Library which used just these tools (variables
and looping) and it was painfully slow and would not really work for the
application I have in mind. I am uncertain if the code in that example
can be modified to make it faster.
Any suggestions
about this age-old question/problem, given the many advances of Amibroker
since 2002??
Thanks for any
ideas (the more specific the better).
Ken
__._,_.___
Please note that this group is for discussion between users only.
To get 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
__,_._,___
|