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

RE: [amibroker] Re: ranking



PureBytes Links

Trading Reference Links

Not sure what you want but I think you can get that information is several
ways. For large numbers of stocks the easiest/fastest would be to use the
explorer however you can also sort and extract the top tickers with afl,
below (was posted before) is a Demo function. For Demo purposes it scores by
the last closing price, this makes it easy to verify operation when you
start tinkering with the code: Compare Chart-table with Exploration and/or
Chart. For you use you should substitute your own Scoring formula in the
getScore function.

Good luck,
herman

function GetScore( )
	{
//	return RSI();	// substitute you own scroring formula here and comment out
the one below
	return C; 		// substitute C for easy verification
	}

function padString( InString, Length )
	{
	SpaceFill= "          ";
	SL 		= StrLen(InString);
	NS			= StrLeft(SpaceFill, Length-SL);
	return NS+Instring;
	}

procedure getPositionScores( WatchList, BarNum, NumTickers )
	{
	global toptickerlist, TickerList;
	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 = LastValue(GetScore());
		RestorePriceArrays();
		TickerScores[n] 	= Temp;
		TickerIndex[n] 	= n;
		}

	TickerCount= n;

	// Sort Tickers by rank
	for(i = n; i>=0; i--)
		{
		for (j = 1; j <= i; j++)
			{
			if (TickerScores[j-1] > TickerScores[j])
				{
				temp = TickerScores[j-1]; TickerScores[j-1] = TickerScores[j];
				TickerScores[j] = temp;
				temp = TickerIndex[j-1]; TickerIndex[j-1] = TickerIndex[j];
				TickerIndex[j] = temp;
				}
			}
		}

	TopTickerList  = TopTickerNum = TopTickerScore = Toptickerlist 	= "";

	if( NumTickers > TickerCount ) NumTickers = TickerCount;

	// Format Top Tickers for Indicator Title verification
	TickersCounted = 0; i=0; P=8;
	for(n=TickerCount; n>=TickerCount-NumTickers; n--)
		{
		T5[i++] 		= TickerIndex[n];
		Ticker 		= StrExtract(Tickerlist,T5[i-1]);
		Score  		= NumToStr(TickerScores[n],1.3);
		TickerNum 	= NumToStr(TickerIndex[n],1.0);
		StaticVarSet(Ticker+"Score",TickerScores[n]);
		StaticVarSet(Ticker+"Number",TickerIndex[n]);
		StaticVarSet(Ticker+"Rank",n);
		TopTickerList 	= TopTickerList + PadString(Ticker,P)+",";
		TopTickerScore = TopTickerScore + PadString(Score,P)+",";
		TopTickerNum 	= TopTickerNum + PadString(TickerNum,P)+",";
		}

	StaticVarSetText("TopTickerList",TopTickerList);
	StaticVarSetText("TopTickerScore",TopTickerScore );
	StaticVarSetText("TopTickerNum ",TopTickerNum );
	}


BarNum = BarCount-1;
Watchlist = Param("Watchlist Number",0,0,100,1);
NumTickers = Param("Number Of symbols to show On the Chart",2,2,10,1);

getPositionScores( WatchList, BarNum, NumTickers );

TopTickerScore =StaticVarGetText("TopTickerScore");
TopTickerList	=StaticVarGetText("TopTickerList");
TopTickerNum 	=StaticVarGetText("TopTickerNum ");

Plot(C,"",1,128);

Tstr =
"\nWatchlist Number: "+NumToStr(WatchList,1.0)+
"\nPosition Scores: \n"+TopTickerList + "\n"+TopTickerScore;
Title = StrLeft(Tstr,1000);

Filter = Status("LastBarInRange");
SetOption("NoDefaultColumns",False);
AddColumn(getScore(),"Score",1.3);









 -----Original Message-----
From: Brian [mailto:cadvantag@xxxxxxxxxxxxxx]
Sent: Monday, February 28, 2005 8:47 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: ranking



Good Luck On This!!

I have been waiting for over a year for amibroker to Rank stocks
based on indicators like Relative Strength, etc




--- In amibroker@xxxxxxxxxxxxxxx, Sidney Kaiser <s9kaiser@xxxx>
wrote:
> Did we ever find some straightforward way to rank a list of
securities on
> some indicator or attribute?
>
> Lets say I want to rank a list based on stochastic.  I would need
to
> generate a ranked list and be able to access the rank position.
>
> In rotational trading positionscore is a ranking.  Can this be
used in the
> following manner?
>
> positionscore = stochd(Close);
>
> positionscore = ROC(positionscore, 5);   This would be the 5 day
delta
> ranking...maybe
>
> Bottom line I need a fairly simple was to rank the list and a way
to fins
> the change in ranking over a few days.
>
> TIA
> Sid
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 266.5.1 - Release Date:
2/27/2005





Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html


Yahoo! Groups Sponsor
ADVERTISEMENT






Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/

To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> 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/