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

[amibroker] Re: top10 [once again]



PureBytes Links

Trading Reference Links

Applications:
//Remove all symbols from WL10, select the top5 RSI(130) from WL5 and 
send them into WL10.
top=5;ORigin=5;destination=10;
g=0;x=0;k=0;topList="";M="";
List=CategoryGetSymbols(categoryWatchlist,ORigin);
for(d=1;d<=top;d++)
{
for(i=0;(sym=StrExtract(List,i))!="";i++)
{
SetForeign(sym);
x=RSI(130);
RestorePriceArrays();
g=IIf(x>g,x,g);
}
for(i=0;(sym=StrExtract(List,i))!="";i++)
{
SetForeign(sym);
x=RSI(130);
topList=topList+WriteIf(x==g,sym,"")+WriteIf(x==g,",","");
M=M+WriteIf(X!=G,SYM,"")+WriteIf(X!=G,",","");
}
List=m;g=0;x=0;m="";
}
List1=CategoryGetSymbols(categoryWatchlist,destination);
for(i=0;(sym=StrExtract(List1,i))!="";i++)
{
CategoryRemoveSymbol(sym, categoryWatchlist, destination ); 
}
for(a=0;a<top;a++)
{
CategoryAddSymbol(StrExtract(toplist,a), categoryWatchlist, 
destination ); 
}
Filter=1;// any current stock for the n=1 last quotations
AddTextColumn(topList,"top"+WriteVal(top,1.0)+"List");
//After the exploration, hit View->Refresh all

Notes:
1. The above code works only for positive arrays.
For MACDs, ROCs, CCIs and other negative arrays, just change g=0 into 
an adequate negative g=-1000, or the possible lowest for the under 
examination array
2. g value may act like a threshold filter. If, instead of g=0 we 
write g=70, then the code will find the top5 of stocks with RSI(130)
>70. If there are not 5 stocks, it will give less. If g=0 and the 
indicator is MACD(), then the code will find the top5 of the 
*positive* MACDs.
3. Note that g is fould in Ln4 and in Ln22 and should be replaced in 
both locations.
4. The indicator is in  Ln11 and Ln18. When you try another example, 
do not forget to replace RSI(130) in both locations.
5. With a few changes we may have the bottom5 : 
g should be the highest possible and the basic selection inequality 
g=IIf(x>g,x,g);
should be reversed into 
g=IIf(x<g,x,g);
6. g is the floor [or the ceiling] of x values. It is the 
generalisation of min(a1,a2) [or respectively max(a1,a2)], it is 
something like a moving min, it compares two numbers and keep in 
memory the greater [respectively the smaller] for the next cycle. It 
is a way to overcome the max(a1,max(a2,max(a3,...)))
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
wrote:
> Here is another solution for the top10 list of WL5, as for the 
Stochd
> () array.
> 
> // TOP LIST
> top=10;WLno=5;
> g=0;x=0;k=0;topList="";M="";
> List=CategoryGetSymbols(categoryWatchlist,WLno);
> for(d=1;d<top;d++)
> {
> for(i=0;(sym=StrExtract(List,i))!="";i++)
> {
> SetForeign(sym);
> x=StochD();
> RestorePriceArrays();
> g=IIf(x>g,x,g);
> }
> for(i=0;(sym=StrExtract(List,i))!="";i++)
> {
> SetForeign(sym);
> x=StochD();
> topList=topList+WriteIf(x==g,sym,"")+WriteIf(x==g,",","");
> M=M+WriteIf(X!=G,SYM,"")+WriteIf(X!=G,",","");
> }
> List=m;g=0;x=0;m="";
> }
> Filter=1;// any current stock for the n=1 last quotations
> AddTextColumn(topList,"top"+WriteVal(top,1.0)+"List of WL"+WriteVal
> (WLno,1.0));
> Title="top"+WriteVal(top,1.0)+"List of WL"+WriteVal(WLno,1.0)
> +" : "+topList;
> 
> Use it in IB or AA, the topList is free [outside any loop] for 
> further use.
> The trick was to remove from the initial list the top stock of each 
> cycle. No composites, no auxiliary arrays, quite fast, no external 
> plugins, it seems good...
> Dimitris Tsokakis


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 

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/