PureBytes Links
Trading Reference Links
|
A different approach to obtaining in this case the top 20 of
whatever you want to rank. Arrays are ROR1 - value of top ranking,
Ind1 - Ordinal Number of top ranked share. ROR2 - 2nd top ranking
etc. In AA window set apply to - Current Stock. Range From - To-
whatever is your desired period. AFL is a bit "longwinded" but can
be easily expanded to rank top 30 etc.
Andrew
In AA window paste the
// ****************************************************************
// APPLY TO - CURRENT STOCK - Select any
// RANGE - FROM - TO - ,
// Explore
// ****************************************************************
Swatchlist = 3; //set watchlist #
sBegBar = LastValue( ValueWhen( Status("firstbarinrange"),
BarIndex() ) );
sEndBar = LastValue( ValueWhen( Status("lastbarinrange"),
BarIndex() ) );
ROR1 = 0; Ind1 = 0; // Highest ROR
ROR2 = 0; Ind2 = 0; // 2nd highest ROR etc.
ROR3 = 0; Ind3 = 0;
ROR4 = 0; Ind4 = 0;
ROR5 = 0; Ind5 = 0;
ROR6 = 0; Ind6 = 0;
ROR7 = 0; Ind7 = 0;
ROR8 = 0; Ind8 = 0;
ROR9 = 0; Ind9 = 0;
ROR10 = 0; Ind10 = 0;
ROR11 = 0; Ind11 = 0;
ROR12 = 0; Ind12 = 0;
ROR13 = 0; Ind13 = 0;
ROR14 = 0; Ind14 = 0;
ROR15 = 0; Ind15 = 0;
ROR16 = 0; Ind16 = 0;
ROR17 = 0; Ind17 = 0;
ROR18 = 0; Ind18 = 0;
ROR19 = 0; Ind19 = 0;
ROR20 = 0; Ind20 = 0;
//today = DateNum();
List = GetCategorySymbols( categoryWatchlist, Swatchlist);
for (j=0; (sTicker = StrExtract (List , j)) !=""; j++ )
{
// ---------------------------------------------------------------
// Insert ranking formula here - return result as "ROR"
// ---------------------------------------------------------------
sClose = Foreign(STicker, "C");
ROR =RSIa( sClose , 14 );
// -----------------------------------------------------------------
// end of ranking formula
// -----------------------------------------------------------------
RORempty = IsEmpty(ROR);
Industry = j; //xxStockPropertyGet(STicker, "IndustryID");
i = sBegBar;
while(i <= sEndBar)
{
if (RORempty[i] == 0 && ROR[i] > ROR1[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR8[i] ;
ROR8[i] = ROR7[i] ; ROR7[i] = ROR6[i] ;
ROR6[i] = ROR5[i] ; ROR5[i] = ROR4[i] ;
ROR4[i] = ROR3[i] ; ROR3[i] = ROR2[i] ;
ROR2[i] = ROR1[i] ; ROR1[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Ind8[i] ;
Ind8[i] = Ind7[i] ; Ind7[i] = Ind6[i] ;
Ind6[i] = Ind5[i] ; Ind5[i] = Ind4[i] ;
Ind4[i] = Ind3[i] ; Ind3[i] = Ind2[i] ;
Ind2[i] = Ind1[i] ; Ind1[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR2[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR8[i] ;
ROR8[i] = ROR7[i] ; ROR7[i] = ROR6[i] ;
ROR6[i] = ROR5[i] ; ROR5[i] = ROR4[i] ;
ROR4[i] = ROR3[i] ; ROR3[i] = ROR2[i] ;
ROR2[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Ind8[i] ;
Ind8[i] = Ind7[i] ; Ind7[i] = Ind6[i] ;
Ind6[i] = Ind5[i] ; Ind5[i] = Ind4[i] ;
Ind4[i] = Ind3[i] ; Ind3[i] = Ind2[i] ;
Ind2[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR3[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR8[i] ;
ROR8[i] = ROR7[i] ; ROR7[i] = ROR6[i] ;
ROR6[i] = ROR5[i] ; ROR5[i] = ROR4[i] ;
ROR4[i] = ROR3[i] ; ROR3[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Ind8[i] ;
Ind8[i] = Ind7[i] ; Ind7[i] = Ind6[i] ;
Ind6[i] = Ind5[i] ; Ind5[i] = Ind4[i] ;
Ind4[i] = Ind3[i] ; Ind3[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR4[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR8[i] ;
ROR8[i] = ROR7[i] ; ROR7[i] = ROR6[i] ;
ROR6[i] = ROR5[i] ; ROR5[i] = ROR4[i] ;
ROR4[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Ind8[i] ;
Ind8[i] = Ind7[i] ; Ind7[i] = Ind6[i] ;
Ind6[i] = Ind5[i] ; Ind5[i] = Ind4[i] ;
Ind4[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR5[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR8[i] ;
ROR8[i] = ROR7[i] ; ROR7[i] = ROR6[i] ;
ROR6[i] = ROR5[i] ; ROR5[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Ind8[i] ;
Ind8[i] = Ind7[i] ; Ind7[i] = Ind6[i] ;
Ind6[i] = Ind5[i] ; Ind5[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR6[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR8[i] ;
ROR8[i] = ROR7[i] ; ROR7[i] = ROR6[i] ;
ROR6[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Ind8[i] ;
Ind8[i] = Ind7[i] ; Ind7[i] = Ind6[i] ;
Ind6[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR7[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR8[i] ;
ROR8[i] = ROR7[i] ; ROR7[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Ind8[i] ;
Ind8[i] = Ind7[i] ; Ind7[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR8[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR8[i] ;
ROR8[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Ind8[i] ;
Ind8[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR9[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR9[i] ; ROR9[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Ind9[i] ; Ind9[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR10[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR10[i];
ROR10[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Ind10[i];
Ind10[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR11[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR11[i]; ROR11[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Ind11[i]; Ind11[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR12[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR12[i];
ROR12[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Ind12[i];
Ind12[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR13[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR13[i]; ROR13[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Ind13[i]; Ind13[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR14[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR14[i];
ROR14[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Ind14[i];
Ind14[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR15[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR15[i]; ROR15[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Ind15[i]; Ind15[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR16[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR16[i];
ROR16[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Ind16[i];
Ind16[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR17[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR17
[i]; ROR17[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Ind17[i]; Ind17[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR18[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR18[i]; ROR18[i] = ROR
[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Ind18[i];
Ind18[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR19[i] )
{ ROR20[i] = ROR19[i]; ROR19[i] = ROR[i] ;
Ind20[i] = Ind19[i]; Ind19[i] = Industry;
} else
if (RORempty[i] == 0 && ROR[i] > ROR20[i] )
{ ROR20[i] = ROR[i] ;
Ind20[i] = Industry;
}
i = i + 1;
}
}
// ----------- COMPLETE -----------
Filter = 1;
AddColumn( Ind1, "ORD 1", 1.0);
AddColumn( ROR1, "Rank1", 1.2);
AddColumn( Ind2, "ORD 2", 1.0);
AddColumn( ROR2, "Rank2", 1.2);
AddColumn( Ind3, "ORD 3", 1.0);
AddColumn( ROR3, "Rank3", 1.2);
AddColumn( Ind4, "ORD 4", 1.0);
AddColumn( ROR4, "Rank4", 1.2);
AddColumn( Ind5, "ORD 5", 1.0);
AddColumn( ROR5, "Rank5", 1.2);
AddColumn( Ind6, "ORD 6", 1.0);
AddColumn( ROR6, "Rank6", 1.2);
AddColumn( Ind7, "ORD 7", 1.0);
AddColumn( ROR7, "Rank7", 1.2);
AddColumn( Ind8, "ORD 8", 1.0);
AddColumn( ROR8, "Rank8", 1.2);
AddColumn( Ind9, "ORD 9", 1.0);
AddColumn( ROR9, "Rank9", 1.2);
AddColumn( Ind10, "ORD 10", 1.0);
AddColumn( ROR10, "Rank10", 1.2);
AddColumn( Ind11, "ORD 11", 1.0);
AddColumn( ROR11, "Rank11", 1.2);
AddColumn( Ind12, "ORD 12", 1.0);
AddColumn( ROR12, "Rank12", 1.2);
AddColumn( Ind13, "ORD 13", 1.0);
AddColumn( ROR13, "Rank13", 1.2);
AddColumn( Ind14, "ORD 14", 1.0);
AddColumn( ROR14, "Rank14", 1.2);
AddColumn( Ind15, "ORD 15", 1.0);
AddColumn( ROR15, "Rank15", 1.2);
AddColumn( Ind16, "ORD 16", 1.0);
AddColumn( ROR16, "Rank16", 1.2);
AddColumn( Ind17, "ORD 17", 1.0);
AddColumn( ROR17, "Rank17", 1.2);
AddColumn( Ind18, "ORD 18", 1.0);
AddColumn( ROR18, "Rank18", 1.2);
AddColumn( Ind19, "ORD 19", 1.0);
AddColumn( ROR19, "Rank19", 1.2);
AddColumn( Ind20, "ORD 20", 1.0);
AddColumn( ROR20, "Rank20", 1.2);
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
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 http://docs.yahoo.com/info/terms/
|