PureBytes Links
Trading Reference Links
|
<SPAN
class=660382012-17062004>Thanks for replying Dimitris; I was wondering when
someone would have a suggestion (:-).
<SPAN
class=660382012-17062004>
<SPAN
class=660382012-17062004>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.
<SPAN
class=660382012-17062004>
<SPAN
class=660382012-17062004>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.
<SPAN
class=660382012-17062004>
<SPAN
class=660382012-17062004>Make sense? When you buy, you're looking for the stocks
ranked highest THAT DAY, which will change every bar.
<SPAN
class=660382012-17062004>
<SPAN
class=660382012-17062004>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.
<SPAN
class=660382012-17062004>
<SPAN
class=660382012-17062004>Any ideas, AFL or Osaka?
<SPAN
class=660382012-17062004>
<SPAN
class=660382012-17062004>Dave
<BLOCKQUOTE
>Dave,The
following code will select from WL61 the top5 STOCHDs, then it will
createa new topList and , finally, apply the trading system.You only
need to explore *ANY* ticker for the n=1 last quotationslist =
CategoryGetSymbols( categoryWatchlist, 61 );g=-100;//SHOULD BE LOWER THAN
ANY POSSIBLE METRIC VALUEt="";topList="";i1=0;nt=5;// calibrate here
the topXfor(n=1;n<=nt;n++){for( i = 0; ( sym = StrExtract(
list, i ) ) != "" ; i++ ){SetForeign(sym);x=StochD();//the
individual
metrict=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
rulesAddColumn(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 Sponsor
ADVERTISEMENT
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 the Yahoo! Terms of Service.
|