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

[amibroker] Re: A complete top10 application



PureBytes Links

Trading Reference Links

Whatever, it's okay, don't be afffraid, things will get better.

--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
wrote:
> Fred,
> Yesterday I was affraid you don't read the text.
> Now I am sure you don't read the text.
> Your question does not refer to [any line of ] this text.
> I will not reply irrelevant questions, please ask in a separate 
> thread, if you wonder if "100 bars make for a meaningful test ".
> FYI, my "final Equities ", the LastValue(Equity(1,0)) are for *all 
> quotations*.
> It was printed in bold,  for easy reading.
> For the numerical part of my example, the test period was Jan2000 
> till now.
> The reader may use his own set of *all quotations*, there is no 
> restriction.
> I presented an AFL method to select the N100 top10, according to 
some 
> criterion and apply an investigation on this top10 selection 
> automatically, without moving this top10 group in a separate watch 
> list and call them back. It is written in the very first lines of 
the 
> text.
> It was a kind of reply to the recent question " Re: getting values 
> from multiple stocks at once". I admit it is not "at once", it has 
> two steps, but it walks towards this direction .
> As for the 101 bars of "~RankY", they are the 101 tickers of the 
N100 
> database, as clearly written in the text you don't read.
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <fctonetti@xxxx> wrote:
> > Does 100 bars make for a meaningful test ?
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Dimitris Tsokakis" 
> <TSOKAKIS@xxxx> 
> > wrote:
> > > 
> > > We shall find first the top10 final Equities of the #1. Steve 
> > Karnish StoRSI [simple] trading system.
> > > Then we shall see their performance with the #2. Steve Karnish 
> > StoRSI with an MA(C,21) trend qualifier.
> > > The procedure has two steps.
> > > 
> > > Step1.
> > > Create the composite ticker "~RankY" which has transformed the 
> 101 
> > final Equities into an array with the last 101 bars 
> > > equal one to one to the respective Lastvalue(E0).
> > > Scan all stocks, all quotations with
> > > 
> > > // #1. Steve Karnish StoRSI [simple]
> > > StochRsi=EMA((RSI(8)-LLV(RSI(8),8))/(HHV(RSI(8),8)-LLV(RSI
> (8),8)),3)
> > *100;
> > > Buy=Cross(17,StochRsi);
> > > Sell=Cross(StochRsi,83);
> > > Short=Cross(StochRsi,83);
> > > Cover=Cross(17,StochRsi);
> > > E0=LastValue(Equity(1,0));
> > > Filter=1;AddColumn(Status("STOCKNUM"),"ORD",1.0);AddColumn
> (E0,"E0");
> > > // VHTr, Vertical to horizontal transformation, by D. Tsokakis, 
> Apr 
> > 2003
> > > x=Status("stocknum");
> > > y=E0;z=LastValue(Cum(1))-x;
> > > Ry=AddToComposite(IIf(z==Cum(1),y,-1e10),"~RankY","C");
> > > Buy=0;
> > > 
> > > Now, the ~RankY is already created.
> > > You may see in Indicator builder with
> > > 
> > > // top10 graph
> > > R= Foreign("~RankY","C");H0=Foreign("~RankY","C");
> > > L1=LastValue(Cum(1));
> > > N=101;// the N100 database population
> > > TOP=10;// calibrate here the topX selection
> > > for(K=1;K<=TOP;K++)
> > > {
> > > H1=LastValue(HHV(H0,n));
> > > BAR1=LastValue((ValueWhen(H0==H1,Cum(1)-1)));
> > > H0[BAR1]=-10;
> > > }
> > > Plot(IIf(Cum(1)>L1-N,R,-1E10),"["+WriteVal(L1-1-BarIndex(),1.0)
> > +"]",IIf(H0==-10,colorYellow,colorBlack),2);
> > > 
> > > In the title line you may read the ordinal number of each stock 
> and 
> > the respective final Equity.
> > > The top10 stocks are painted yellow.
> > > 
> > > Step2.
> > > We shall see now the performance of this top10 group in the 
> system 
> > #2.
> > > 
> > > Explore the N100 database, for the n=101 last quotations with
> > > 
> > > // PERFORMANCE OF THE SELECTED TOP10 IN ANOTHER SYSTEM
> > > // EXPLORE THE DATABASE FOR THE LAST 101 QUOTATIONS
> > > X=Status("STOCKNUM");
> > >  R= Foreign("~RankY","C");H0=Foreign("~RankY","C");
> > > L1=LastValue(Cum(1));
> > > N=101;// the N100 database population
> > > TOP=10;// calibrate here the topX selection
> > > for(K=1;K<=TOP;K++)
> > > {
> > > H1=LastValue(HHV(H0,n));
> > > BAR1=LastValue((ValueWhen(H0==H1,Cum(1)-1)));
> > > H0[BAR1]=-10;
> > > }
> > > ORD=IIf(H0==-10,L1-1-BarIndex(),-1E10);
> > > // #2. Steve Karnish StoRSI [MA(C,21)]
> > > /*The Buy signal is accepted if the 21-bar MA is ascending the 
> same 
> > day.
> > > The Short signal is accepted if the 21-bar MA is descending the 
> > same day*/
> > > StochRsi=EMA((RSI(8)-LLV(RSI(8),8))/(HHV(RSI(8),8)-LLV(RSI
> (8),8)),3)
> > *100;
> > > Buy=Cross(17,StochRsi) AND Ref(MA(C,21),-1) < MA(C,21);;
> > > Sell=Cross(StochRsi,83);
> > > Short=Cross(StochRsi,83) AND Ref(MA(C,21),-1) > MA(C,21);
> > > Cover=Cross(17,StochRsi);
> > > E=LastValue(Equity(1,0));
> > > Filter=H0==-10 AND X==ORD;
> > >  AddColumn(ORD,"ORD",1.0);
> > > AddColumn(E,"E");
> > > 
> > > In the results you may see the final performance of the 
> preselected 
> > System #1 top10 performers.
> > > 
> > > Dimitris Tsokakis
> > > 
> > > Note1
> > > In Equity settings we used 
> > > Buy/Sell/Short/Cover at Open
> > > Delay=+1
> > > commission 0.5%
> > > Initial equity 10000
> > > All stops disabled
> > >  Note2
> > > In the selection Step1, any ranking criterion may be used. To 
> > select, for example, the top10 RSI() values, just replace 
> > > y=E0 with y=Lastvalue(RSI())
> > > Note3
> > > The most time consuming step was step2, it needs ~3sec for the 
> N100 
> > database, using Amibroker 4.41b with a PIII/800
> > > 64Mb RAM/10Gb HD.
> > > The step1 scan takes less than a [reliable] second.
> > > Note4
> > > The method has obvious advantages compared to my previous 
> loopless 
> > attempt of 
> > > http://groups.yahoo.com/group/amibroker/message/38650
> > > Now, thanks to for AFL loop, the code is almost the same for a 
> top5 
> > or a top10 ranking.
> > > In the #38650 form, one should change the code according to X 
for 
> > each topX.
> > > Dimitris Tsokakis
> > > ----- Original Message ----- 
> > > From: Dimitris Tsokakis 
> > > To: amibroker@xxxxxxxxxxxxxxx 
> > > Sent: Sunday, September 07, 2003 1:30 PM
> > > Subject: To continue with
> > > 
> > > 
> > > Here is an even shorter code to find the top10 StochD values 
from 
> > the last 100 bars.
> > > Paste in indicator builder the
> > > 
> > > // Top10 from 100
> > > R=StochD();
> > > H0=StochD();
> > > L1=LastValue(Cum(1));
> > > N=100;// the lookback period
> > > TOP=10;// the topX calibration
> > > for(K=1;K<=TOP;K++)
> > > {
> > > H1=LastValue(HHV(H0,n));
> > > BAR1=LastValue((ValueWhen(H0==H1,Cum(1)-1)));
> > > H0[BAR1]=-10;
> > > }
> > > Plot(IIf(Cum(1)>L1-N,R,-1E10),"",IIf(H0==-
> > 10,colorYellow,colorBlack),2);
> > > 
> > > Since we paint the top10 points outside the loop execution, we 
> know 
> > all the rest details, when it happened, the respected value, 
> outside 
> > the loop, 
> > > consequently the result is ready for any further use.
> > > The trick was to find the highest value, find the bar it 
happens 
> > and then, in the very next step, make this value negative [-10 in 
> the 
> > example]. 
> > > The next cycle of the loop will search for the 2nd highest 
value 
> > etc.
> > > For other indicators, replace -10 with another, enough negative 
> > value, lower than the usual indicator values, to ensure that you 
> will 
> > excude this
> > > bar from the next cycle of the loop. If you do not know the 
> > negative values, a Lowest(Indicator)-1 is enough.
> > > Dimitris Tsokakis
> > > 
> > > ----- Original Message ----- 
> > > From: Dimitris Tsokakis 
> > > To: amibroker@xxxxxxxxxxxxxxx 
> > > Sent: Saturday, September 06, 2003 10:59 PM
> > > Subject: To begin with
> > > 
> > > 
> > > Let us find the top10 of the last 100 Stochd() values.
> > > In AA explore the current stock for the last 100 bars.
> > > // The top10 of an exploration
> > > bars=100;
> > > H1=StochD()*(LastValue(Cum(1))-Cum(1)<bars);
> > > H11=H1;
> > > H2[0]=0;Counter=0;
> > > top=10;
> > > for(n=1;n<=top;n++)
> > > {
> > > for(i=1;i<BarCount;i++)
> > > {
> > > H2=LastValue(Highest(H1));
> > > if(H1[i]==H2[i])
> > > {
> > > if(Counter<top)
> > > {
> > > H1[i]=0;
> > > Counter=Counter+1;
> > > }
> > > }
> > > }
> > > }
> > > Filter=1;
> > > AddColumn(H11,"Array");
> > > AddColumn((H1==0)*H11,"Top10");
> > > 
> > > In the "Top10" column you read the 10 highest StochD() values, 
> all 
> > the rest are 0.
> > > Dimitris Tsokakis


------------------------ 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/