Sidney - I think you're not storing your
ticker symbols in the table for one. This is from the forum....note how he
builds 3 columns, extracts the
ticker, calculates RSQP and stuff the
ticker, the closing values, RSQP etc while iterating down the rows, with each
row dedicated to an
issue. The sort is then based on a
column.
One of my lessons learned is that you have
to stuff a value in the table and not an array....note the use of
LastValue(RSQP) etc below.
Another lesson learned is that you can run this in the commentary window
and readily get the output without using DebugView with _TRACE.
This is only a clip and the first part of a larger AFL; and if
you don't have this AFL write me directly and I'll ship it to you.
Hope this helps
JOE
// Name : RS Proto Osaka.afl
First attempts at storing Rel Strength and sorting on // rank.
osInitialize();
table = osTabCreate(); osTabAddColumn(
"my first column", 2, table,30 ); osTabAddColumn( "my
second column2", 1, table, 30 ); osTabAddColumn(" my third
column3", 1,table,30); // Set the parameters //
Listnum = Param("Watch List",
6,0,63,1); // does it work in
commentary?? Listnum = 6; // Get
contents of watch
list str =
GetCategorySymbols(categoryWatchlist,Listnum); // loop through tickers in the
watchlist
for( i = 0; (member=StrExtract(str,i))!="";
i++ ) { CX = Foreign(member,"Close");
ticker = StrExtract(str,i); osTabSetString( ticker , i, 0,
table ); // first column ticker tickerval =
LastValue(Cx); RSQP =
(.04*Cx/(.001+Ref(Cx,-62))+.02*Ref(Cx,-63)/(.001+Ref(Cx,-125))+.02*Ref(Cx,-
126)/(.001+Ref(Cx,-188)) + .02*Ref (
Cx,-189)/(.001+Ref(Cx,-251)))*100;
RSQP = LastValue(RSQP);
osTabSetNumber(tickerval,i,1,table); // write closing value
osTabSetNumber(RSQP , i,2,table ); // write
close RS value in 3rd column }
----- Original Message -----
Sent: Wednesday, July 06, 2005 12:58
AM
Subject: [amibroker] Ranking, Osaka plug
in
In another attempt to rank in a different manner I
spent a week or so trying the get the Osaka plug in to produce ranked
results. I have been able to get it to do only the simplest of
tasks. As soon as I try to set it up to actually rank some real
indicator values I have severe problems with the AB code to get the symbols
and indicator values into Osaka, let alone trying to get the supposedly ranked
values out of the table. I have read all the Osaka related posts and
tried all the code examples, no joy.
Hers is some code I have been
working with. There is probably more than one error in
here.
/* The code below should be
explored against a smallish watchlist, say 20 symbols. It creates AND
saves a table while the first stock is being processed, AND instead of
recreating it for subsequent stocks, loads it from disk. The idea is that
if lots of processing was required to create the table (unlike this simple
test), it'd only have to be done once for the whole test run.
Dave
Merrill ---------------------- */
// CONFIG List = 14; // watchlist to examine; must be list under test; 14 = C8080
list NumberOfTestColumns = 5; // 66, three
months of data per stock MomPer = 14; // Optimize("MomPer", 14, 4, 21, 1);
// FUNCTIONS
function
fListLen(List) { i = 0;
while
(StrExtract(List, i) !=
"") i++;
return i; }
// init TickerList = CategoryGetSymbols
(categoryWatchlist, List); CountTickers = fListLen(TickerList);
StockNum = Status( "StockNum"
); // #
of stocks in the list FirstStock = (StockNum ==
0);
// init table, make col for each bar in test osInitialize(); table = osTabCreate(); osTabAddColumn ("Symbol" , 2, table, StrSize=6);
if (FirstStock) {
for(i = 1; i <= NumberOfTestColumns; i++) {
osTabAddColumn
("MAM" + i, 1, table);
}
osTabSave( else {
osTabLoad( ColCount = osTabGetColumnCount (table);
// Now fill the columns with
some useful data. //
CALCULATING SCORES and saving them to the table // this area is new and
needs testing score = 100*(Close /MA(Close, (2*MomPer) +1) -1); // MAM
for (i=0; (ticker = StrExtract (TickerList, i)) !=
""; i++ ) {
SetForeign
(ticker); osTabSetString( ticker, i, 0,
table ); // the table is filling with
the symbols and fixed data, but no MAM
for( j =
0; j <=
NumberOfTestColumns; j++ ) { osTabSetNumber( score[ j ], i, j ,
table ); } } osTabExport ("MAM_table_fill.csv" ,"," , table); // Sort the table
osTabSort(table, 5 ); // sort by last column, 66 Output =
""; for( i = 0; i < 10; i++ ) // top ten MAM rankings { Output =
Output + osTabGet(
i, 0, table ) +
", " +
osTabGet( i,
1 , table ) +
"\n"; // symbol and rank }
Output;
Filter = 1; //Status("LastBarInTest"); AddColumn (ColCount, "ColCount" , 1.0); AddColumn (StockNum, "StockNum" , 1.0); AddColumn (CountTickers, "CountTickers" , 1.0); AddColumn(table, "table" , 1.0); AddColumn(score, "MAM", 7.1); //AddColumn(MAM, "Rank");
// clean up osTabDelete (table);
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 other support material please check
also: http://www.amibroker.com/support.html
---- LSpots keywords ?>---- HM ADS ?>
No virus found in this outgoing message. Checked by AVG
Anti-Virus. Version: 7.0.323 / Virus Database: 267.8.8/37 - Release Date:
7/1/2005
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 other support material please check also:
http://www.amibroker.com/support.html
---- LSpots keywords ?>
---- HM ADS ?>
YAHOO! GROUPS LINKS
|