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

Re: [amibroker] Sorting Top 20% stocks



PureBytes Links

Trading Reference Links




You need to modify the source watchlist, the dest 
watchlist and topN 
below and run 
this script in Explore:
 
/*  Puts top N stocks based on user defined 
formula and sorting  to a given watchlist. Additionaly the whole table 
is exported to file "topN.CSV"    Requires ABtool.dll plugin 
(<A 
href="">http://groups.yahoo.com/group/abtool)  
  Must  be run with "ApplyTo=current stock", "Range=n last quotes, 
n=1".
 
  Written by Uenal Mutlu (UM) 
030625We*/xxWinClose();#include "ABtool/Functions.afl"
 
srcWL = 60;  // set thisdstWL = 15;  // set 
thistopN  = 10;  // set this
 
if (status("stocknum") == 0)  
{    th = xxTableCreate();    
xxTableColumnAdd("Ticker",   xxSTRING, th);    
xxTableColumnAdd("Date",     xxSTRING, 
th);    xxTableColumnAdd("Turnover", xxFLOAT,  
th);    row      = 
0;    aDatenum = datenum();    
barLast  = xxRangeBarLast();    nTickers = 
xxWLtickerCount(srcWL);    ticker   = 
xxWLtickerFirst(srcWL);    while (ticker != 
"")    {   // xxWinText(ticker + "\n"); 
      aC  = foreign(ticker, 
"C");      aV  = foreign(ticker, 
"V");      tov  = MA(aC * aV, 32);   
// your formula      xxTableDataAddStr(ticker, row, 
0, th);      
xxTableDataAddStr(xxABdatenumToDatestr(aDatenum[barLast]), row, 1, 
th);      xxTableDataAddNum(tov[barLast], row, 2, 
th);      ticker = 
xxWLtickerNext(srcWL);      row++;   
    }    xxTableSort(th, 2, 
false);    xxWLclear(dstWL);    iTickers = 
min(topN, xxTableGetRowCount(th));    for (i = 0; i < 
iTickers; i++)      
{        ticker = 
xxTableDataGet(i,0,th);        
xxWinText(ticker + "\n");        
xxWLaddTicker(ticker, dstWL);      
}    xxTableExport("TopN.csv", ",",th);  // export table 
to CSV    xxTableDelete(th);    
xxWLrefresh(); // xxViewRefresh();    xxWinText("--- 
finished --- \n");   }
 
 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Michael.S.G. 
  
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Thursday, June 26, 2003 12:42 
  AM
  Subject: Re: [amibroker] Sorting Top 20% 
  stocks
  Dang, Almost 
  missed this message, Being CarbonCopy - Email Filter Missed it.I might 
  Just have to check it out. (AB-Tool that 
  is.)KR        Michael.At 
  03:34 PM 25/06/2003 +0200, you wrote:
  In pure AFL this 
    is IMHO not possible, but using the ABtool plugin<FONT 
    face=arial>you can do this all with just one click on the Explore 
    button.But ABtool best operates on Watchlists, 
    so putting all yourstocks to scan into any of 
    the 64 possible watchlists makesthe ABtool code 
    much simpler. Help on ABtool you can getin the 
    ABtool group (<FONT 
    face="Times New Roman, Times">http://groups.yahoo.com/group/abtool<FONT 
    face=arial>).UM 
    
      ----- Original Message ----- 
      From: Michael.S.G. 
      To: <A 
      href="">amibroker@xxxxxxxxxxxxxxx 
      Sent: Wednesday, June 25, 2003 2:45 PM
      Subject: Re: [amibroker] Sorting Top 20% stocks
      At the moment, I just use this:
      Filter = <FONT 
      face="Courier New, Courier" color=#ff00ff>1;
      TurnOver = <FONT face="Courier New, Courier" 
      color=#0000ff>MA(Close * Volume,<FONT 
      face="Courier New, Courier" color=#ff00ff>32);
      <FONT face="Courier New, Courier" 
      color=#0000ff>AddColumn(TurnOver, <FONT face="Courier New, Courier" 
      color=#ff00ff>"TurnOver", <FONT face="Courier New, Courier" 
      color=#ff00ff>1.2);
      Then Manualy sort the column and then add the top 100 to a 
      watchlist.
      (Via excel - Because selecting 100 lines in the results window is 
      painfull).
      I would prefer to just be able to run one explore & import to a 
      watchlist or parse with more filters.
      I will look at other ways of achiveing this - Possibly via 
      JScript......
      KR
       Michael.
      At 09:06 AM 25/06/2003 +0200, you wrote:
      
        Hi, just a tip: I think you should reformulate what you are 
        trying to achieve or solve. IMHO AddToComposite is
        not necessary for this.
        UM
        ----- Original Message ----- 
        From: "Michael.S.G." <OzFalcon@xxxxxxxx>
        To: <amibroker@xxxxxxxxxxxxxxx>
        Sent: Wednesday, June 25, 2003 3:35 AM
        Subject: [amibroker] Sorting Top 20% stocks
        > -----BEGIN PGP SIGNED MESSAGE-----
        > Hash: SHA1
        > 
        > I would like to be able to make a selection of stocks - Based 
        on  Top
        > 20% Turnover.
        > 
        > After Looking at the UserGuide and Downloadable AB Archives I 
        have
        > created the following AFL..
        > Using the AddToComposite function and running a Scan then 
        Explore,
        > I can't seem to be able to get the AddToComposite part to 
        work.
        > 
        > Perhaps I am tring to make a Square Wheel Roll, If there is an 
        easier
        > way of Ranking/Selection - Please do tell!
        > 
        > Also, I have AA set to "Last 1 Quotation".
        > 
        > /* Aimed Percentage to select (APS %) */
        > APS = 20;
        > AP = ((100 - aps)/100);
        > 
        > Filter = 1;
        > 
        > TurnOver = MA(Close * Volume,32);
        > AddColumn(TurnOver, "TurnOver", 1.2);
        > AddColumn(AP, "AP", 1.2);
        > 
        > /* AddToComposite statements are for Automatic Analysis -> 
        Scan */
        > /* add Close price to our index OHLC fields */
        > 
        > /* Make ATC a Highest Value - Doesn't Work... */
        > FC =  Foreign( "~MyIndex", "V");
        > aTO = IIf (TurnOver > FC,(Turnover - fc), 0);
        > // Can't figure out why this doesnt
        > // increase V. Perhaps Circular?
        > AddToComposite(aTO, "~MyIndex", "V" );
        > 
        > /* add one to open intest field (we use this field as a 
        counter) */
        > AddToComposite( 1, "~MyIndex", "I" );
        > 
        > Buy = 0; // required by scan mode
        > 
        > /* this part is for Indicator Builder */
        > // Graph0 = Foreign( "~MyIndex", "C" )/Foreign( "~MyIndex", "I" 
        );
        > 
        > FT = Foreign( "~MyIndex", "V");
        > IT = Foreign( "~MyIndex", "I" );
        > AddColumn(FT,"FT-ForeignTally",1.2);
        > AddColumn(IT,"CounterTally",1.2);
        > AddColumn(aTO,"To Add",1.2);
        > 
        > //Filter = Turnover > (Foreign( "~MyIndex", "V" ) * ap);
        > 
        > 
        > Any Help Appreciated.
        > KR
        > 
Michael.






Yahoo! Groups Sponsor












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.