Dear Members,
Below is a ranking function that helps me rank stocks according to various
criteria and produce new tickers with position in watchlist. I run it using
exploration.
For some reason it stopped working. Firstly I got a NumColumns error which I
sorted by adding a dummy column and then it stopped producing new tickers. I
never had these problems before. It stopped working after I copied AB from my
desktop onto my laptop to keep them in sync.
Can anyone please advise on what can be possibly broken?
function GetScore(index)
{
test=C;
return test[index]; // substitute C
for easy verification
}
function getPosition(watchlist,index)
{
local TickerList;
// read my value
// SetForeign(tick);
my_score = GetScore(index);
// RestorePriceArrays();
TickerList = GetCategorySymbols( categoryWatchlist,
WatchList);
// Create zero-based Scores array in wrt to current data
for( n=0; (Ticker=StrExtract( TickerList, n)) != ""; n++)
{
SetForeign(Ticker);
Temp = GetScore(index);
RestorePriceArrays();
TickerScores[n] = Temp;
TickerIndex[n] = n;
}
TickerCount= n;
my_position = 0;
// how many are bigger than my value
for(i=0;i<=n;i++) {
if(TickerScores[i] > my_score)
my_position++;
}
return my_position;
}
Watchlist = 1;
local positions;
for(i=0;i<BarCount;i++) {
positions[i] = getPosition(WatchList,i);
}
AddToComposite(positions,"~test" + Name(),"C");
//Plot(positions,"position in WatchList",1,30);
//Plot(StaticVarGet("count"),"position in WatchList",1,30);
Filter = Status("LastBarInRange");
//SetOption("NoDefaultColumns",False);
AddColumn(positions,"positions",1.3);
Buy=False;
Sell=False;
BR,
Michal