[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Ranking function



PureBytes Links

Trading Reference Links

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

 



------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/