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

[amibroker] top10 in one step



PureBytes Links

Trading Reference Links




We may avoid the two steps [run the ~RankY and then 
select the top10] thanks to the [relatively new] function 
GetCategorySymbols().
I have my N100 database in 
Group254.
It contains 101 tickers, the ^NDX index and the 100 
stocks.
Let us find the top10 last RSI values of this 
group.
Paste in Indicator Builder the
 
// top10 Selection<FONT face=Verdana 
size=2>
function<FONT 
face="Times New Roman"> select( listnum )
{<FONT 
face="Times New Roman">
list = GetCategorySymbols<FONT 
face=Verdana size=2>( 
categoryGroup, listnum );<FONT 
face="Times New Roman">
Rank = 0; g=<FONT 
size=2>BarIndex<FONT 
face="Times New Roman">();
for( i = <FONT 
size=2>0; ( sym = StrExtract<FONT 
size=2>( list, i ) ) != ""<FONT face=Verdana 
size=2>; i++ 
)
{<FONT 
face="Times New Roman">
C1 = Foreign( sym, 
"C"<FONT 
face="Times New Roman"> );<FONT 
face="Times New Roman">
f=LastValue(<FONT 
size=2>RSIa(C1,14<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">));<FONT 
face="Times New Roman">
Rank[BarCount-1<FONT face=Verdana 
size=2>-i] = 
f[i];
}
return<FONT face=Verdana 
size=2> Rank ; 

}
No=254; // replace 254 
with the GroupNo of your database<FONT 
face="Times New Roman">
R= Select(No);
H0=Select(<FONT face=Verdana 
size=2>No);<FONT 
face="Times New Roman">
L1=LastValue(<FONT 
size=2>Cum(1<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">));<FONT 
face="Times New Roman">
N=101<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;<FONT 
face="Times New Roman">
TOP=10<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;<FONT face=Verdana 
size=2>
for(K=1<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">;K<=TOP;K++)
{<FONT 
face="Times New Roman">
H1=LastValue(<FONT 
size=2>HHV<FONT 
face="Times New Roman">(H0,n));<FONT 
face="Times New Roman">
BAR1=LastValue((<FONT 
size=2>ValueWhen(H0==H1,Cum<FONT 
size=2>(1)-<FONT 
size=2>1<FONT 
face="Times New Roman">)));<FONT 
face="Times New Roman">
H0[BAR1]=-10<FONT face=Verdana 
size=2>;
}<FONT 
face=Verdana size=2>
Plot(IIf<FONT 
size=2>(Cum(<FONT 
size=2>1)>L1-N,R,-1E10<FONT 
size=2>),"["+<FONT 
size=2>WriteVal(L1-1<FONT 
size=2>-BarIndex(),<FONT 
size=2>1.0)+"]"<FONT 
size=2>,IIf(H0==-<FONT 
size=2>10,colorYellow,colorBlack),<FONT 
size=2>2<FONT 
face="Times New Roman">);
 
This one-step 
procedure produces the same selection graph with the two-steps procedure 
.
The top10 stocks are painted yellow outside the loop and are 
ready for further use.
Dimitris 
Tsokakis
 






Yahoo! Groups Sponsor


  ADVERTISEMENT 









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



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



Attachment:
11rank.gif

Attachment: Description: "Description: GIF image"