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

[amibroker] Re: The top5 of an exploration



PureBytes Links

Trading Reference Links

Jerome,
many thanks for the details.
DT
--- In amibroker@xxxxxxxxxxxxxxx, "Silvarius" <silvarius@xxxx> wrote:
> Dimitri,
> 
> 1 - Vertical/Horizontal transformation : I think I had 
misunderstood your
> terminology. I thought your "vertical/horizontal transformation" 
process
> applied to the chart that you included in  your mail. I don't 
understand the
> use of this chart.
> 
> 2 - Sorting out the top 5 : your code is perfectly valid. I just 
thought a
> "for" loop would be more flexible, allowing to sort out the "top X" 
instead
> of the "top 5". But I still have version 4.30 installed, so I 
cannot use
> loops yet on my computer. But the code should look something like 
that
> (after having created the "rankY" composite) :
> 
> H0 = Foreign("~rankY","C");
> NbTickers = 101;
> Counter = Cum(1);
> IdBar = Counter - BarCount + NbTickers + 1; //array containing the 
Status
> number of each stock
> NbTops = 5;  //Number of tops considered
> 
> TopValue[BarCount - 1] = HHV(H0,n);  //Top value of the top 5
> TopId[BarCount - 1] = ValueWhen(IdBar,H0 == HHV(H0,n),n);  //Status 
of the
> stock having the top value
> 
> for(i=1;i<NbTops;i++)
>     {
>     for(j = BarCount - NbTickers;j<BarCount;j++)
>         {
>         if(H0[j] > TopValue[BarCount - i - 1] && H0[j] <=
> TopValue[BarCount - i] && j != TopId[BarCount - i])
>             {
>             TopValue[BarCount - i -1] = H0[j]; //Value of the next 
top 5
>             TopId[BarCount - i -1] = IdBar[j]; //Status of the next 
top 5
>             }
>         }
>      }
> 
> The value and Status of the top 5 are stored in 5 last bars of the
> "TopValue" and "TopId" arrays. To sort out more than 5 stocks, just 
change
> the value of the "NbTop" variable. Equal values are not a problem. 
You can
> also store the values for further use in a new composite ticker. 
This code
> should be run only for the "~rankY" ticker.
> 
> If you have stored the "TopValue" and "TopId" arrays in a new 
composite
> ticker ("~Top5" for example), and want to filter out these top 5 
stocks in
> an exploration, you should be able to do like that :
> 
> NbTops = 5;
> TopId = Foreign("~Top5","C");//Status array of our top performers
> 
> for(i = BarCount - NbTops;i < BarCount;i++)
>       if(TopId[i] == Status("StockNum")
>            Filter[BarCount - 1] = 1;
> 
> Please note that this code has not been tested. It is only to 
illustrate the
> idea of extracting and using the TopX performers through loops.
> 
> Best regards, Jérôme ULRICH
> 
> 
>   -----Message d'origine-----
>   De : DIMITRIS TSOKAKIS [mailto:TSOKAKIS@x...]
>   Envoyé : jeudi 24 avril 2003 10:18
>   À : amibroker@xxxxxxxxxxxxxxx
>   Objet : [amibroker] Re: The top5 of an exploration
> 
> 
>   Jerome,
>   thank you for the interesting reply.
>   See comments below
> 
>   --- In amibroker@xxxxxxxxxxxxxxx, "Silvarius" <silvarius@xxxx> 
wrote:
>   > Hello Dimitri,
>   >
>   > Why do you need this transformation vertical/horizontal ? Once 
you
>   have the
>   > result of your exploration stored in "~rankY" ticker,
> 
>   but, the "~RankY" *is* the tsansformation
> 
>   >it seems simpler to
>   > sort out the top five through a "for" loop.
> 
>   Is it possible to be more specific with some code?
> 
>   >And if you want to store these
>   > top five for further use in AB, you can put them in the five 
last
>   bars of a
>   > new ticker.
> 
>   How?
>   >
>   > Best regards, Jerome ULRICH
>   >   -----Message d'origine-----
>   >   De : Dimitris Tsokakis [mailto:TSOKAKIS@x...]
>   >   Envoye : jeudi 24 avril 2003 09:16
>   >   A : amibroker@xxxxxxxxxxxxxxx
>   >   Objet : [amibroker] The top5 of an exploration
>   >
>   >
>   >   1. The VHTr transformation
>   >   To Explore N100 for the last RSI, select the top5 and see 
their
>   > performance to a trading system,
>   >   run first in AA for all stocks, all quotations the
>   >
>   >   // VHTr, Vertical to horizontal transformation, by D. 
Tsokakis,
>   Apr 2003
>   >   x=Status("stocknum");
>   >   y=LastValue(RSI());z=LastValue(Cum(1))-x;
>   >   Ry=AddToComposite(IIf(z==Cum(1),y,-1e10),"~RankY","C");
>   >   Buy=0;
>   >   Filter=1;
>   >   AddColumn(Y,"INDICATOR",1.3);
>   >   AddColumn(x,"STOCKNUM",1.0);
>   >
>   >   An atificial ticker "~RankY" is just created. It is a bit
>   peculiar, it has
>   > values for the last 101 bars only.
>   >   [My N100 database has 101 names, the 100 stocks plus the index
>   ^NDX
>   > itself]
>   >   From left to right, each bar of the new array is equal to the
>   exploration
>   > result. The 1st is YHOO, the last is ^NDX,
>   >   exactly inversed from the alphabetic sorting in my Symbol 
tree.
>   But, this
>   > ticker is a normal array and accepts any
>   >   array treatment. For example, we may find the top5 values.
>   >   Suppose, for the simplicity, that there are no equal values* 
and
>   paste in
>   > IB the
>   >
>   >   H0=Foreign("~RankY","C");
>   >   L1=LastValue(Cum(1));
>   >   n=101;// the population of the database
>   >   H1=LastValue(HHV(H0,n));
>   >   BAR1=LastValue((ValueWhen(H0==H1,Cum(1))));
>   >   H2=LastValue(HHV(IIf(H0<H1 ,H0,0),n));
>   >   BAR2=LastValue((ValueWhen(H0==H2 ,Cum(1))));
>   >   H3=LastValue(HHV(IIf(H0<H1 AND H0<H2,H0,0),n));
>   >   BAR3=LastValue((ValueWhen(H0==H3 ,Cum(1))));
>   >   H4=LastValue(HHV(IIf(H0<H1 AND H0<H2 AND H0<H3,H0,0),n));
>   >   BAR4=LastValue((ValueWhen(H0==H4 ,Cum(1))));
>   >   H5=LastValue(HHV(IIf(H0<H1 AND H0<H2 AND H0<H3 AND
>   H0<H4,H0,0),n));
>   >   BAR5=LastValue((ValueWhen(H0==H5 ,Cum(1))));
>   >   COLOR=IIf(H0==H1 OR H0==H2 OR H0==H3 OR H0==H4 OR H0==H5,7,1);
>   >   Plot(H0,"",COLOR,2);GraphXSpace=3;
>   >   Title= "[ NUM1="+WriteVal(L1-BAR1,1.0)+",H1="+WriteVal(H1,1.2)
>   +"]"+
>   >   "[ NUM2="+WriteVal(L1-BAR2,1.0)+",H2="+WriteVal(H2,1.2)+"]"+
>   >   "[ NUM3="+WriteVal(L1-BAR3,1.0)+",H3="+WriteVal(H3,1.2)+"]"+
>   >   "[ NUM4="+WriteVal(L1-BAR4,1.0)+",H4="+WriteVal(H4,1.2)+"]"+
>   >   "[ NUM5="+WriteVal(L1-BAR5,1.0)+",H5="+WriteVal(H5,1.2)+"]";
>   >
>   >   The top5 values are paited yellow and, in the title, you read 
5
>   pairs
>   > [STOCKNUM,RSI]
>   >   The #14 [ BRCD ] is the champion with RSI=77.43 and the top5 
is
>   >   BRCD, ICOS, SPOT, PCAR, BRCM
>   >   We read in IB title the results of the exploration [all 
stocks,
>   n=1 last
>   > quotations] of VHTr.
>   >   2. The use of the VHTr transformation
>   >   Explore now all stocks, n=1 last quotations with the
>   >
>   >   X=Status("STOCKNUM");
>   >   H0=Foreign("~RankY","C");L1=LastValue(Cum(1));
>   >   n=101;
>   >   H1=LastValue(HHV(H0,n));
>   >   BAR1=LastValue((ValueWhen(H0==H1,Cum(1))));
>   >   H2=LastValue(HHV(IIf(H0<H1 ,H0,0),n));
>   >   BAR2=LastValue((ValueWhen(H0==H2 ,Cum(1))));
>   >   H3=LastValue(HHV(IIf(H0<H1 AND H0<H2,H0,0),n));
>   >   BAR3=LastValue((ValueWhen(H0==H3 ,Cum(1))));
>   >   H4=LastValue(HHV(IIf(H0<H1 AND H0<H2 AND H0<H3,H0,0),n));
>   >   BAR4=LastValue((ValueWhen(H0==H4 ,Cum(1))));
>   >   H5=LastValue(HHV(IIf(H0<H1 AND H0<H2 AND H0<H3 AND
>   H0<H4,H0,0),n));
>   >   BAR5=LastValue((ValueWhen(H0==H5 ,Cum(1))));
>   >   Cond=X==L1-bar1 OR X==L1-bar2 OR X==L1-bar3 OR X==L1-bar4 OR
>   X==L1-bar5;
>   >   Buy=Cross(RSI(),35);Sell=Cross(RSI(),65);// THE TRADING SYSTEM
>   >   e=LastValue(Equity());
>   >   Filter=COND;
>   >   AddColumn(X,"STOCKNUM",1.0);
>   >   AddColumn(E,"EQUITY");
>   >
>   >   You will see the final equity value for the top5 stocks.
>   >   Dimitris Tsokakis
>   >   *another set will be posted to treat the possibility of equal
>   values in
>   > the result list.
>   >
>   >         Yahoo! Groups Sponsor
>   >         [AD]
>   >
>   >
>   >   Send BUG REPORTS to bugs@xxxx
>   >   Send SUGGESTIONS to suggest@xxxx
>   >   -----------------------------------------
>   >   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.
> 
> 
>         Yahoo! Groups Sponsor
> 
> 
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   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.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/Z_CBYA/vB5FAA/AG3JAA/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/