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

Re: [amibroker] Re: Top 200 stocks by volume



PureBytes Links

Trading Reference Links




Dave
 
I've finally been able to reproduce your 
finding.  This occurs when there are Data holes (no trading days) in the 
shares being analysed.  A partial fix is to modify the following 
line
 
    
for (j=0; (sTicker = StrExtract( List,j)) 
!= ""; j++)
    {<FONT 
color=#0000ff>
>    
SetForeign(sTicker);
    Rank = 
Ranking(Sov1,Sov2,Sov3,Sov4);
    k = StartBar;
 
to  SetForeign<FONT face=Arial 
size=2>(sTicker,false);
 
This will prevent filling data holes (see helpfile 
SetForeign - Fixup), but this is only a partial fix.  The Data holes still 
cause problems
Run this small exploration and you will find that 
the Ref Date array is different if there are data holes.  In the Ranking 
AFL I posted, everything is referenced back to the current stock periods (ie. 
the indexes periods).  This means that a 250 period MA looks at our 
SetForeign Ticker for 250 index periods.  The Second AFL you posted 
calculates the 250 period MA over 250 Ticker periods.  Data gaps will 
result in different calculations for the MA.

// Apply to - Use Filter 
- set to desired watchlist
// Range From - set date To - Same date (one day range)<FONT 
face="Courier New" size=1>
Refdate = <FONT face="Courier New" color=#0000ff 
size=1>Ref(<FONT 
face="Courier New" color=#0000ff size=1>DateNum<FONT face="Courier New" 
size=1>(),-20<FONT 
face="Courier New" size=1>);
Filter = <FONT face="Courier New" color=#ff00ff 
size=1>1;<FONT 
face="Courier New" color=#0000ff size=1>
AddColumn(Refdate,<FONT 
face="Courier New" color=#ff00ff size=1>"Ref Date"<FONT 
face="Courier New" size=1>,<FONT face="Courier New" color=#ff00ff 
size=1>1.0);<FONT 
face="Courier New" color=#ff00ff size=1> 
The Solution,  A start would be to remove tickers from your watchlist 
that have data holes (realistically only those that have excessive holes).  
If your like me, You wouldn't want to trade something that doesn't trade every 
day anyway.  The Total solution would be to have the AFL reject tickers 
that trade less than a certain % of periods.  I'm working on something 
related to this in another project.  I'll get back to you when I've 
finished.
 
Out of interest, What market are you trading  - ASX ?
 
Andrew 

<FONT 
color=#000000> 
<FONT 
color=#000000> 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=dcrotty2003@xxxxxxxxxxxx 
  href="">dcrotty2003 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Sunday, December 21, 2003 8:40 
  PM
  Subject: [amibroker] Re: Top 200 stocks 
  by volume
  Hi Andrew,Yes, I did run the ranking using 
  Turnover=MA(V*C,250) in it.Another thing I have just done is run 
  this:Filter=MA(V*C,250);SetOption("NoDefaultColumns", 
  True);AddTextColumn( Name(), "Ticker", 77);AddColumn( DateTime(), 
  "        
  Date        ", 
  formatDateTime);AddColumn( Close, "   Close   ", 
  1.3);AddColumn(MA(V*C,250), "Turnover", 1);...on a single date and 
  exported the data to a CSV file and on sortedthe volume top to 
  bottom.I compared it with the same date on the ~TurnoverTop200 and the 
  value in the ~TurnoverTop200 would catch around 180 stocks when 
  looking at the volume in the csv file. Thanks.Dave--- In 
  amibroker@xxxxxxxxxxxxxxx, "Andrew Perrin" <adjp@xxxx> 
  wrote:> Dave> Had to think about this one, I noticed you 
  have used Turnover=MA(V*C,250) . This is not the turnover calculation used 
  in the initial Ranking AFL, did you modify that ranking calculation as 
  well, if notthat is the reason for the discrepancy.  It does work 
  for me. > > >BTW I would like to do an Explore on single day 
  (say on01/01/2003) > >using for an example: MA(V*C,250) so I can 
  do a sort in AA to see what > >the actual Top 200 stocks symbols 
  were. I've tried a few thing but I'm > >not sure how to set it 
  up in the AA and what range to set (ie:does it > >need to be 
  back 250 days for the 250 day MA) ?> > Just set Range From - 
  01/01/2003 To - 01/01/2003 and explore.  No you don't have to worry 
  about 250 day MA, Amibroker takes care ofthat for you.> 
  > Andrew> > >   ----- Original Message 
  ----- >   From: dcrotty2003 >   To: 
  amibroker@xxxxxxxxxxxxxxx >   Sent: Sunday, December 21, 2003 
  8:40 AM>   Subject: [amibroker] Re: Top 200 stocks by 
  volume> > >   Hi Andrew,> 
  >   I just did a simple scan to see exactly how many stocks 
  wereabove the >   turnover formula in the rank code 
  ie:> >   Turnover=MA(V*C,250)  >= 
  Foreign("~TurnoverTop200","C");>   Buy = 
  0;>   AddToComposite(Turnover, "~StockNum", "X" ); > 
  >   ...I found the number of stocks picked on a day varies 
  between170 & >   180 or so, rather then 200. Do 
  you know why this would be? Thanks.> >   BTW I would 
  like to do an Explore on single day (say on01/01/2003) 
  >   using for an example: MA(V*C,250) so I can do a sort in 
  AA to see what >   the actual Top 200 stocks symbols 
  were. I've tried a few thingbut I'm >   not sure how 
  to set it up in the AA and what range to set (ie:does it 
  >   need to be back 250 days for the 250 day MA) ?> 
  >   Dave> > > >   --- 
  In amibroker@xxxxxxxxxxxxxxx, "Andrew Perrin" <adjp@xxxx> 
  >   wrote:>   > Dave>   
  > Good to hear you got it working.  I don't run this exact 
  scan,but yes I >   do run a ranking scan daily.  
  I contributed the Turnover Rankingas an >   
  example,  Perhaps of interest to you was a discussion on whether this 
  >   particular formula for turnover was the best as opposed 
  to MA(V * >   Close ,sov1). >   > see <A 
  href="">http://groups.yahoo.com/group/amibroker-ts/message/596 
  for >   this discussion>   > >Just 
  add MA(V,sov1) * Close >= foreign>   > 
  >("~Top200Vol","C"); to my system and that's it. Does thatsound 
  OK?>   > What you suggest sounds right to 
  me>   > Andrew>   > 
  >   > >   >  >   
  > >   > ----- Original Message ----- 
  >   >   From: dcrotty2003 >   
  >   To: amibroker@xxxxxxxxxxxxxxx >   
  >   Sent: Saturday, December 20, 2003 4:22 PM>   
  >   Subject: [amibroker] Re: Top 200 stocks by 
  volume>   > >   > >   
  >   Andrew,>   > >   
  >   Excellent!! :-) got it going, thanks for your time and 
  yourcode. I >   didn't >   
  >   understand how it worked and now that I see it on a chart, I 
  doesn't >   >   look like it's necessary to 
  do it month by month as Imentioed in my >   
  >   previous post. Just add MA(V,sov1) * Close >= 
  foreign>   >   ("~Top200Vol","C"); to my system 
  and that's it. Does thatsound OK?>   > 
  >   >   Do you run this daily prior to Scaning 
  for signals?>   > >   >   
  Thanks again.>   >   Dave>   
  > >   > >   >   --- In 
  amibroker@xxxxxxxxxxxxxxx, "Andrew Perrin" <adjp@xxxx> 
  >   >   wrote:>   
  >   > Dave>   >   > to use 
  this AFL, you need to set the APPLY TO -> CURRENT >   
  >   STOCK       not Filter -> 
  Watchlist -> 1000 stocks.  For the current >   
  stock >   >   selected it is best to use a stock 
  with no data holes ( I usean >   INDEX ).  
  >   >   I've copied a snippet of code from the 
  AFL below, this iswhat I tried >   to 
  >   >   explain in first comment.  Under 
  user variables are>   >   > sWatchlist = 
  4;  This is the watchlist you want to scan not write 
  >   >   results to.  Set this to whatever 
  you mistakenly set thefilter to >   
  initially.>   >   >  Rank_No = 
  200;  This is the depth you want to rank to ie.the 
  >   200th >   >   highest rank 
  value will be added to the AddToComposite.>   
  >   > >   >   > // 
  >   >   >   
  ****************************************************>   
  >   ************>   >   > // 
  APPLY TO - CURRENT STOCK - Set to an index (no data 
  holes).>   >   > // RANGE - FROM - "set 
  date" TO - "set date",>   >   > // SCAN or 
  EXPLORE>   >   > // >   
  >   >   
  ****************************************************>   
  >   ************>   >   > 
  osInitialize();>   >   > #pragma 
  nocache>   >   > //#include 
  "afl/AP_Functions.afl";>   >   > 
  //////////////////////////////////////////////////>   
  >   > // User Variables - enter here //>   
  >   > 
  /////////////////////////////////////////////////>   
  >   > sWatchlist = 4; // set to desired 
  watchlist.>   >   > Rank_No = 100; // set the 
  depth to rank to.>   >   > 
  >   >   > >   
  >   > Hope this Helps,  any problems just 
  ask>   >   > >   
  >   > Andrew>   >   
  >   ----- Original Message ----- >   
  >   >   From: dcrotty2003 >   
  >   >   To: amibroker@xxxxxxxxxxxxxxx 
  >   >   >   Sent: Saturday, 
  December 20, 2003 9:50 AM>   >   
  >   Subject: [amibroker] Re: Top 200 stocks by 
  volume>   >   > >   
  >   > >   >   >   
  Hi Andrew, thanks for your reply.>   >   > 
  >   >   >   Re: Add To Composite 
  RankValue based on Ranking calculation.>   
  >   > >   >   >   
  Using the code in the message you wrote, I believe Icould use 
  >   the >   >   
  >   composite value as a filter in my systems 
  backtest.>   >   > >   
  >   >   I could run the top 200 volume code over 
  each month forthe last>   >   
  >   couple of years, setting up watchlists/composites to 
  usein >   >   backtesting. 
  >   >   > >   
  >   >   Then in my system, add a date function for 
  each of the months >   >   >   
  composites as a volume filter for backtesting over the1000 
  >   stocks.>   >   > 
  >   >   >   ie:>   
  >   >   IIf(Year()==2003 AND Month()==11,MA(V,sov1) 
  * Close >= >   foreign>   
  >   >   
  ("~Top200Vol_11_2003","C"),>   >   
  >   IIf(Year()==2003 AND Month()==12,MA(V,sov1) * Close >= 
  >   foreign>   >   
  >   ("~Top200Vol_12_2003","C"),    
  >   >   > >   
  >   >   ....etc etc etc >   
  >   > >   >   >   
  Nothing's never that easy is it!! ...hoping for a 
  simplerway.>   >   > >   
  >   >   Anyway down to business :-) I've downloaded 
  the Osakaplug-in >   and >   
  >   run >   >   >   
  the code on a watchlist of 1000 stocks. I get thecomposite come 
  >   up >   >   >   
  with zero and nothing in my watchlist 4. In the AAresults all 
  the>   >   >   Rank Values are 
  zero.>   >   > >   
  >   >   Any idea what I could be doing wrong? I'm 
  selecting Applyto ->>   >   
  >   Filter -> Watchlist -> 1000 stocks and setting the 
  dateto the last >   >   >   
  months worth. I'm using AB Version 4.5.6 and I guessthere's 
  >   nothing>   >   
  >   to setup in the Settings?>   
  >   > >   >   >   
  Thanks, Dave>   >   > >   
  >   > >   >   >   
  --- In amibroker@xxxxxxxxxxxxxxx, "Andrew" <a.perrin@xxxx> 
  >   >   wrote:>   
  >   >   > Dave>   
  >   >   > Take a look at messages 50428 and 
  50457.  They might be >   what >   
  >   you >   >   >   
  want>   >   >   > 
  >   >   >   > 
  Andrew>   >   >   > 
  >   >   >   > --- In 
  amibroker@xxxxxxxxxxxxxxx, "dcrotty2003" >   >   
  >   <dcrotty2003@xxxx> >   
  >   >   > wrote:>   
  >   >   > > Hi Mark, and thanks for the 
  reply.>   >   >   > > 
  >   >   >   > > Sounds a bit 
  tricky, I have no knowledge of JScript.>   >   
  >   > > >   >   
  >   > > Would anyone have already coded something similar 
  in >   JScript >   >   that 
  >   >   >   > > Mark 
  suggested and I may be able to modify it.>   >   
  >   > > >   >   
  >   > > Otherwise, any other suggestions on how to do it? 
  Thanks.>   >   >   > > 
  >   >   >   > > 
  Dave>   >   >   > > 
  >   >   >   > > --- In 
  amibroker@xxxxxxxxxxxxxxx, "Mark H" >   >   
  <amibroker@xxxx> >   >   >   
  wrote:>   >   >   > > > I 
  haven't tried that, but based on what I read inthe help 
  >   file, >   >   
  >   > > you can do an automatic script to accomplish 
  that.>   >   >   > > > 
  >   >   >   > > > 1. load 
  the explore formula and settings>   >   
  >   > > > 2. invoke the explore>   
  >   >   > > > 3. save the results to a 
  file>   >   >   > > > 4. 
  read the file and choose the top 200 tickers>   
  >   >   > > > 5. clear existing 
  watchlist>   >   >   > > > 
  6. set the 200 tickers to watchlist>   >   
  >   > > > >   >   
  >   > > > You can even add the backtest 
  steps:>   >   >   > > > 
  >   >   >   > > > 7. load 
  the backtest formula and settings>   >   
  >   > > > 8. invoke the backtest>   
  >   >   > > > 9. save the reports to 
  files.>   >   >   > > > 
  >   >   >   > > > All 
  these can be done in JScript. After that, thewhole >   
  process >   >   >   > is 
  >   >   >   > > just one 
  click away.>   >   >   > > 
  > >   >   >   > > > - 
  Mark H.>   >   >   > > 
  >   ----- Original Message ----- >   
  >   >   > > >   From: dcrotty2003 
  >   >   >   > > 
  >   To: amibroker@xxxxxxxxxxxxxxx >   
  >   >   > > >   Sent: Thursday, 
  December 18, 2003 4:51 PM>   >   
  >   > > >   Subject: [amibroker] Top 200 
  stocks by volume>   >   >   > 
  > > >   >   >   > > 
  > >   >   >   > > 
  >   Hi,>   >   >   
  > > > >   >   >   > 
  > >   From a newbie EOD trader. Instead of backtesting 
  using >   >   todays >   
  >   >   > > index, >   
  >   >   > > >   is it possible to 
  create a daily list of 200 onlystocks from >   
  >   >   > a >   >   
  >   > > list >   >   
  >   > > >   of 1000 filtered by moving average 
  volume and my >   system >   
  >   >   > > backtested on >   
  >   >   > > >   this 
  list?>   >   >   > > > 
  >   >   >   > > 
  >   I know I could do an explore to pick out the top200 
  and >   >   save >   
  >   >   > it >   
  >   >   > > to a >   
  >   >   > > >   watchlist then 
  backtest on the list, but I wantthe list to >   be 
  >   >   >   > > 
  >   changed everyday within the backtest.>   
  >   >   > > > >   
  >   >   > > >   I don't want if 
  using the rank function to onlybuy top->   down 
  >   >   >   > > stocks 
  >   >   >   > > 
  >   with the highest volume but to buy any of the 200 
  >   selected >   >   
  >   > stocks.>   >   
  >   > > > >   >   
  >   > > >   Thanks for any 
  help.>   >   >   > > > 
  >   >   >   > > 
  >   Dave> > > >   Send BUG 
  REPORTS to bugs@xxxx>   Send SUGGESTIONS to 
  suggest@xxxx>   
  ----------------------------------------->   Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
  >   (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)>   
  -------------------------------------------->   Check group 
  FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  > > > > 
  ------------------------------------------------------------------------------>   
  Yahoo! Groups Links> >     a.. To visit your 
  group on the web, go to:>     <A 
  href="">http://groups.yahoo.com/group/amibroker/>       
  >     b.. To unsubscribe from this group, send an 
  email to:>     
  amibroker-unsubscribe@xxxxxxxxxxxxxxx>       
  >     c.. Your use of Yahoo! Groups is subject to 
  the Yahoo! Terms of Service.Send BUG REPORTS to 
  bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  
  
  Yahoo! Groups Links
  
    To visit your group on the web, go to:<A 
    href="">http://groups.yahoo.com/group/amibroker/  

    To unsubscribe from this group, send an email to:<A 
    href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

    Your use of Yahoo! Groups is subject to the <A 
    href="">Yahoo! Terms of Service. 
  


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





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.