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

[amibroker] Re: VFI Performance - How do I .....?



PureBytes Links

Trading Reference Links

Tomasz,
Here is another question:
The

list = CategoryGetSymbols( categoryWatchlist, 10 );
T="";
for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; i++ )
{
T=T+sym+",";
}
Title=T;

gives CSCO,GRMN,INTC even before 14/12/2000. But, GRMN has no data 
before 14/12/2000.
I would expect an output CSCO,INTC before 14/12/2000, if 
CategoryGetSymbols() was a properly working daily function.
Still confused with this.
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
wrote:
> Tomasz,
> I suppose [a] that the output of the
> 
> list = CategoryGetSymbols( categoryWatchlist, 10 );
> n=0;
> for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; i++ )
> {
> n=n+1;
> }
> Plot(n,"n",1,1);
> 
> will be the population of WL10.
> I also suppose [b] that the output of
> 
> list = CategoryGetSymbols( categoryWatchlist, 10 );
> n=0;
> for(j=0;j<BarCount;j++)
> {
> for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; i++ )
> {
> n[j]=n[j]+1;
> }
> }
> Plot(n,"n",1,1);
> 
> will be the population of WL10.
> My WL10 includes CSCO [FROM Jan3, 2000] , INTC [FROM Jan3, 2000] 
and 
> GRMN[FROM Dec14, 2000, since there was no GRMN before]
> Both above codes give a flat n=3 for all bars.[v. 4.50.6]
> Is any code wrong ?
> Is there another code to find the population of WL10 through 
> CategoryGetSymbols() function ?
> How can I have the same result with
> 
> AddToComposite(1,"~WL10pop","V");
> Buy=0;
> 
> ?
> These questions make me think that CategoryGetSymbols() does not 
Get 
> the Symbols per bar.
> This is what I call improper.
> Please advise.
> Dimitris Tsokakis
> PS: We have had a similar discussion some time ago. Your final 
reply 
> was to adopt two [different] definitions for the average. Shall we 
> have two definitions for the population of a WL ?
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
<amibroker@xxxx> 
> wrote:
> > Hello,
> > 
> > Just a note:
> >  CategoryGetSymbols works properly REGARDLESS of alignment/data 
> holes/etc.
> > 
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message ----- 
> > From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Saturday, June 19, 2004 11:39 AM
> > Subject: [amibroker] Re: Example of buying top N stocks ranked by 
> some metric - no takers?
> > 
> > 
> > > Glenn,
> > > 
> > > Here is the code
> > > 
> > > // The top5 list
> > > list = CategoryGetSymbols( categoryWatchlist, 61 );
> > > g=-100;t="";topList="";i1=0;
> > > nt=5;// calibrate here the topX
> > > for(n=1;n<=nt;n++)
> > > {
> > > for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; i++ )
> > > {
> > > SetForeign(sym);
> > > x=StochD();//the individual metric
> > > t=WriteIf(x>g,sym,t);i1=IIf(x>g,i,i1);
> > > g=Max(g,x);
> > > }
> > > topList=topList+t+",";L0="";
> > > for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; i++ )
> > > {
> > > SetForeign(sym);
> > > L0=L0+ WriteIf(i!=i1,sym+",","");
> > > }
> > > List=L0;g=-100;
> > > }
> > > Title="The top"+WriteVal(nt,1.0)+"list for "+Date()+" 
> is "+topList;
> > > 
> > > For 3/5/2004, for example, The top5list of N100 is 
> > > WFMI,LNCR,MEDI,EBAY,XRAY in IB title.
> > > [The Title will be the same for any ticker in the symbol 
tree...]
> > > In AA, from 3/5/2004 to 3/5/2004 the exploration results of
> > > 
> > > Filter=1;
> > > AddColumn(StochD(),"StochD");
> > > 
> > > are
> > > WFMI, 86.88
> > > LNCR, 84.92
> > > MEDI, 77.18
> > > EBAY, 76.35
> > > XRAY, 74.40
> > > 
> > > The stocks of WL61 should be aligned [no missing quotes, no 
extra 
> > > quotes], else the CategoryGetSymbols() function will not work 
> > > properly.
> > > Check your database with Tools->Database purify.
> > > Dimitris Tsokakis
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Glenn" <glennokb@xxxx> wrote:
> > > > Hi Dimitris, thanks for the code.
> > > > 
> > > > When I place it in the IB and fill Watchlist 61, I get the 
same 
> > > symbol
> > > > in each of the 5 positions. Would you know why please, has 
> anyone 
> > > else
> > > > found this?
> > > > 
> > > > BTW Dave, I have been looking for a simpler way to finding 
the 
> top N
> > > > stocks using AFL. I am currently using the Osaka plug-in, the 
> code 
> > > I'm
> > > > using with it is in message 50457.
> > > > 
> > > > Cheers Glenn 
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" 
> > > <TSOKAKIS@xxxx>
> > > > wrote:
> > > > > Dave,
> > > > > the topList in my code is a comma separated string.
> > > > > If you run the exploration for more than one [the last or 
> not] 
> > > bars, 
> > > > > the string appears the same [this is the same for any 
> > > AddTextColumn 
> > > > > result, as you probably know].
> > > > > Of course, if you select another single day [say From 
> 2/6/2004 To 
> > > > > 2/6/2004] you will see the topList of this 2/6/2004.
> > > > > It is easier in IB, paste the
> > > > > 
> > > > >  list = CategoryGetSymbols( categoryWatchlist, 61 );
> > > > > g=-100;t="";topList="";i1=0;
> > > > > nt=5;// calibrate here the topX
> > > > > for(n=1;n<=nt;n++)
> > > > > {
> > > > > for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; i++ )
> > > > > {
> > > > > SetForeign(sym);
> > > > > x=StochD();//the individual metric
> > > > > t=WriteIf(x>g,sym,t);i1=IIf(x>g,i,i1);
> > > > > g=Max(g,x);
> > > > > }
> > > > > topList=topList+t+",";L0="";
> > > > > for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; i++ )
> > > > > {
> > > > > SetForeign(sym);
> > > > > L0=L0+ WriteIf(i!=i1,sym+",","");
> > > > > }
> > > > > List=L0;g=-100;
> > > > > }
> > > > > Title="The top"+WriteVal(nt,1.0)+"list for "+Date()+" 
> > > is "+topList;
> > > > > 
> > > > > Put your cursor on a bar and you will have the topX list 
for 
> that 
> > > bar.
> > > > > It is a good starting point for your further study.
> > > > > Dimitris Tsokakis
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Dave Merrill" 
> <dmerrill@xxxx> 
> > > > > wrote:
> > > > > > Thanks for replying Dimitris; I was wondering when 
someone 
> > > would 
> > > > > have a
> > > > > > suggestion (:-).
> > > > > > 
> > > > > > Unfortunately, unless I'm misunderstanding your code, 
it's 
> not 
> > > what 
> > > > > I meant.
> > > > > > It's creating a single watchlist to work off, containing 
> the 
> > > top 5 
> > > > > tickers
> > > > > > by StochD, but that list is the same for every bar.
> > > > > > 
> > > > > > I'll try again to explain: Whenever there's uncommitted 
> > > capital, 
> > > > > buy the
> > > > > > stocks ranked the highest (by StochD for example) ON THAT 
> DAY. 
> > > So 
> > > > > first bar,
> > > > > > I'd buy the 20 stocks with the highest StochD, and hold 
> each of 
> > > > > them until
> > > > > > it exits by a custom AFL rule based on entry price and 
> time. 
> > > > > Whenever
> > > > > > there's free capital, buy as many of the top StochD 
stocks 
> as 
> > > > > there's room
> > > > > > for in the position sizing.
> > > > > > 
> > > > > > Make sense? When you buy, you're looking for the stocks 
> ranked 
> > > > > highest THAT
> > > > > > DAY, which will change every bar.
> > > > > > 
> > > > > > I don't see how to do that in native AFL. I thought I'd 
> seen an 
> > > > > example of
> > > > > > something similar using the Osaka plugin (for its sorting 
> > > > > capability), but I
> > > > > > don't know where.
> > > > > > 
> > > > > > Any ideas, AFL or Osaka?
> > > > > > 
> > > > > > Dave
> > > > > >   Dave,
> > > > > >   The following code will select from WL61 the top5 
> STOCHDs, 
> > > then it
> > > > > >   will create
> > > > > >   a new topList and , finally, apply the trading system.
> > > > > >   You only need to explore *ANY* ticker for the n=1 last 
> > > quotations
> > > > > > 
> > > > > >   list = CategoryGetSymbols( categoryWatchlist, 61 );
> > > > > >   g=-100;//SHOULD BE LOWER THAN ANY POSSIBLE METRIC VALUE
> > > > > >   t="";topList="";i1=0;
> > > > > >   nt=5;// calibrate here the topX
> > > > > >   for(n=1;n<=nt;n++)
> > > > > >   {
> > > > > >   for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; 
i++ )
> > > > > >   {
> > > > > >   SetForeign(sym);
> > > > > >   x=StochD();//the individual metric
> > > > > >   t=WriteIf(x>g,sym,t);i1=IIf(x>g,i,i1);
> > > > > >   g=Max(g,x);
> > > > > >   }
> > > > > >   topList=topList+t+",";L0="";
> > > > > >   for( i = 0; ( sym = StrExtract( list, i ) ) != "" ; 
i++ )
> > > > > >   {
> > > > > >   SetForeign(sym);
> > > > > >   L0=L0+ WriteIf(i!=i1,sym+",","");
> > > > > >   }
> > > > > >   List=L0;g=-100;
> > > > > >   }
> > > > > >   /*The top5 list is already created, apply now the 
trading 
> > > rules*/
> > > > > >   for(j=0;j<nt;j++)
> > > > > >   {
> > > > > >   global Buy;global Sell;
> > > > > >   TICKER=StrExtract(topList,j);
> > > > > >   SetForeign(TICKER,True,True);
> > > > > >   Buy=Cross(StochD(),50);Sell=Ref(Buy,-5);//the trading 
> rules
> > > > > >   AddColumn(Equity(1,0),TICKER);
> > > > > >   }
> > > > > >   Filter=1;
> > > > > >   AddTextColumn(topList,"top"+WriteVal(nt,1.0)+"List");
> > > > > >   AddTextColumn(L0,"The rest");
> > > > > > 
> > > > > >   The topList is temporarily created for the exploration 
> needs, 
> > > if 
> > > > > you
> > > > > >   want to save the topList tickers for further use, 
> > > > > CategoryAddSymbol -
> > > > > >   CategoryRemoveSymbol will do the job.
> > > > > >   The clue is to find first the top ticker and 
> then "subtract" 
> > > it 
> > > > > from
> > > > > >   the comma separated string of the initial list.
> > > > > >   Unfortunately this "string subtraction" is not 
supported. 
> We 
> > > may
> > > > > >   write "MSFT,INTC,CSCO"+",BEAS", but we can not 
> > > > > write "MSFT,INTC,CSCO"-
> > > > > >   "CSCO".
> > > > > >   To solve this I find the ordinal # of the top ticker 
and 
> > > replace 
> > > > > it
> > > > > >   with "". The remaining list will have one ticker less 
> and, at 
> > > this
> > > > > >   stage, we may repeat the top procedure.
> > > > > >   Some steps may be shorter but, DAX is opening...
> > > > > >   Dimitris Tsokakis
> > > > > >   --- In amibroker@xxxxxxxxxxxxxxx, "Dave Merrill" 
> > > <dmerrill@xxxx>
> > > > > >   wrote:
> > > > > >   >
> > > > > >   >   Say I wanted to buy the top 20 stocks ranked by ROC
> (C, 
> > > 1), for
> > > > > >   example,
> > > > > >   > and sell with a custom exit somewhat like a trailing 
> stop, 
> > > one 
> > > > > that
> > > > > >   depends
> > > > > >   > on knowing the entry date and price.
> > > > > >   >
> > > > > >   >   This is the only thing I could come up with, which 
> won't 
> > > do 
> > > > > it,
> > > > > >   because
> > > > > >   > the exit function won't know when buys actually occur 
> > > according 
> > > > > to
> > > > > >   > PositionScore.
> > > > > >   >
> > > > > >   >   Buy = 1;
> > > > > >   >   PostitionScore = Max(ROC(C, 1), 0);
> > > > > >   >   ExitLine = MyExitFunction();
> > > > > >   >   Sell = Cross(ExitLine, C);
> > > > > >   >
> > > > > >   >   Am I being clear? Is there a way to do this in 
native 
> AFL?
> > > > > >   >
> > > > > >   >   Thanks,
> > > > > >   >
> > > > > >   >   Dave
> > > > > >   >     A few more explanations would be required to know 
> what 
> > > you 
> > > > > are
> > > > > >   after.
> > > > > >   >
> > > > > >   >     In both rotational and non-rotational mode you 
can 
> buy 
> > > top N
> > > > > >   stocks
> > > > > >   >     if you code PositionScore variable according to 
> your 
> > > metric.
> > > > > >   >
> > > > > >   >     > Does anyone have a non-rotational example of 
> buying 
> > > the 
> > > > > top N
> > > > > >   stocks
> > > > > >   > ranked
> > > > > >   >     > by some metric? Far as I can see, that requires 
> the 
> > > Osaka
> > > > > >   plug-in,
> > > > > >   > which I'm
> > > > > >   >     > not familiar with.
> > > > > >   >     >
> > > > > >   >     > Thanks,
> > > > > >   >     >
> > > > > >   >     > Dave Merrill
> > > 
> > > 
> > > 
> > > 
> > > Check AmiBroker web page at:
> > > http://www.amibroker.com/
> > > 
> > > Check group FAQ at: 
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > Yahoo! Groups Links
> > > 
> > > 
> > > 
> > >  
> > > 
> > >



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

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/