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

[amibroker] Re: top10 [once again]



PureBytes Links

Trading Reference Links

When we use g as a filter, the top10 list may not have 10 stocks. In 
this case, there was an error in previous formulas. The result was to 
add also the current stock into the destination WL.
To avoid this, we may find the population of this artificial topList 
and add only the top stocks as follows:

//Remove all symbols from WL10, select the top10 Volumes>10,000,000 
from WL5 and send them into WL10.

top=10;ORigin=5;destination=10;
g=10^7;x=0;k=0;topList="";M="";pop=0;
List=CategoryGetSymbols(categoryWatchlist,ORigin);
for(d=1;d<=top;d++)
{
for(i=0;(sym=StrExtract(List,i))!="";i++)
{
SetForeign(sym);
x=V;
RestorePriceArrays();
g=IIf(x>g,x,g);
}
for(i=0;(sym=StrExtract(List,i))!="";i++)
{
SetForeign(sym);
x=V;
topList=topList+WriteIf(x==g,sym,"")+WriteIf(x==g,",","");
M=M+WriteIf(X!=G,SYM,"")+WriteIf(X!=G,",","");
}
List=m;g=10^7;x=0;m="";
}
for(i=0;(sym=StrExtract(topList,i))!="";i++)
{pop=pop+1;}//this is the population of the topList

List1=CategoryGetSymbols(categoryWatchlist,destination);
for(i=0;(sym=StrExtract(List1,i))!="";i++)
{
CategoryRemoveSymbol(sym, categoryWatchlist, destination ); 
}
for(a=0;a<pop;a++)//this line will add only the top10 stocks, even if 
they are less than 10
{
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");
AddColumn(pop,"topList population",1.0);

Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
wrote:
> //the use of g as a filter
> //Remove all symbols from WL10, select the bottom5 RSI(13) [if RSI
(13)
> <40] from WL5 and send them into WL10.
> 
> top=5;ORigin=5;destination=10;
> g=40;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(13);
> RestorePriceArrays();
> g=IIf(x<g,x,g);
> }
> for(i=0;(sym=StrExtract(List,i))!="";i++)
> {
> SetForeign(sym);
> x=RSI(13);
> topList=topList+WriteIf(x==g,sym,"")+WriteIf(x==g,",","");
> M=M+WriteIf(X!=G,SYM,"")+WriteIf(X!=G,",","");
> }
> List=m;g=40;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");
> 
> In this example g=40 acts like an upper threshold, the code will 
try 
> the 5 worse RSIs, if they are below the 40 level, else it will give 
> fewer.
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" 
<TSOKAKIS@xxxx> 
> wrote:
> > 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/