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

Re: [amibroker] Composite Calculations - help



PureBytes Links

Trading Reference Links

I clipped this from one of my routines and I think this will work if the individual watchlists 1...10 contain the tickers from which the indexes are composed.  

1) Select a current symbol with a suitable number bars

2)  Select n last quotations = 1

3)  Run as a SCAN 

Ths should produce 10 tickers ~WLAvg1 to ~WLAvg10 with the average volume in the Volume field. 

You choose how you want to average the price arrays. 

Hope this helps 

Joe 



VolTotal = Count = CountVol = 0; 

for (j =1 ; j<=10; j++)

{

//_TRACE("WL # " + j); 

watchlistsymbols = GetCategorySymbols(categoryWatchlist, j);

for (mem = 0; (member = StrExtract(watchlistsymbols, mem)) != ""; mem++)

{

ticker = Foreign(member, "Close");

//_TRACE("Ticker "+ ticker+" no of member "+ mem); 

tickvol = Nz( Foreign(member, "Volume") );

VolTotal = Voltotal + tickvol; 

countvol = countvol + IIf(IsEmpty(ticker), 0, 1);

}

IndexVolavg = voltotal / countvol;

// Here generate a symbol name for example "~WLAvg01 to "~WLAvg10" 

Listnum = j; // for readability 

if (Listnum < 10)

Listnumstr = StrFormat("%1.0f", Listnum);

else

Listnumstr = StrFormat("%2.0f", Listnum);

AddToComposite(indexvolavg, "~WLAvg" + Listnumstr, "V", atcFlagDefaults + atcFlagEnableInExplore);

} 

Buy = Sell = 0; 

----- Original Message ----- 
  From: Terry 
  To: amibroker@xxxxxxxxxxxxxxx 
  Sent: Wednesday, October 04, 2006 2:10 PM
  Subject: RE: [amibroker] Composite Calculations - help


  You might try using a different variable for list since you have it both as a numeric, then you assign a string to it. This may or may not be causing problems, but I'm guessing it is.



  list==10;

  Comp ="SP-500";



     list = CategoryGetSymbols( categoryWatchlist, list );    

  --

  Terry



  -----Original Message-----
  From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Bill
  Sent: Wednesday, October 04, 2006 12:28
  To: amibroker@xxxxxxxxxxxxxxx
  Subject: [amibroker] Composite Calculations - help



  Hello,

  I like to keep composite data on a dozen or so indices.  If I have a 

  seperate .afl for each index and run it against a watch list 

  containing the components of that index, everything appears to work 

  fine.  However, I've recently been trying to have one .afl access 

  the different watch lists as such:



  if (InWatchList(10)){

  list==10;

  Comp ="SP-500";



     list = CategoryGetSymbols( categoryWatchlist, list );    

     for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ );

  }

  else

  NEXT WATCH List and so on.

  I run this against all the stock components contained in all the 

  indices. database (TC2007).  I know there is duplication with one 

  stock being in more than one index. Again it appears to work just 

  fine however, I receive different answers than 

  when I run it the first way.  Anyone know why this might be?? And 

  what I can do?



  Thanks in Advance for any assistance,



  Bill













  Please note that this group is for discussion between users only.



  To get support from AmiBroker please send an e-mail directly to 

  SUPPORT {at} amibroker.com



  For other support material please check also:

  http://www.amibroker.com/support.html





  Yahoo! Groups Links










      (Yahoo! ID required)




      mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx