Graham:
Many thanks for the specific code and discussion on this
approach. I have just completed a three watchlist test and it went
flawlessly. This will make my processing of the 25 or so sector watchlists
I have very easy.
It remains a mystery to me what TJ does with the magic of
his programming....I had wondered how the ATC commands (which are driven by the
loop code) would process just the symbols of each watchlist after having read
thru all of the symbols in the database. If the first Watchlist contains a
Z symbol and then the second watchlist contains a W symbol, well, it seemed like
the data had to be "stored" someplace until the subsequent ATC statements could
go get them. Or worse, that the entire list would have to be read again
for each pass thru the loop (something TJ would never
allow).
I have 2 G of RAM but a system tray counter did not show
any real decrease in the free memory, and the hard drive only chattered once
(5.25 minutes to read 6200 symbols), then the drive winked for about 10 more
seconds, I assume while the remaining ATCs were completed.
Totally mysterious to me, and a testament to TJs
programming expertise, but irrelevant as long as I get the Composites
automatically named and calculated---and they were.
Again, I am very appreciative that you took the time to
explain the code. Thanks to the others who offered other
suggestions. JScript and Batman approaches are not needed here, although I
will use the BatMan to process some other code to update some rankings of the
new sector averages.
Ken
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Graham
Sent: Wednesday, August 09, 2006 8:47 PM
To: [email protected]
Subject: Re: [amibroker] New Question on Watchlist Averages
AFL goes through completely for each symbol once. Each command is completed before proceeding to the next line in the AFL
the if(inwatchlist(1)) is done then proceeds to the next if statement. when completed it goes to next symbol
AFL will check if each IF statement is true for every symbol and add the appropriate fields to the coomposite
The trick to finding average prices for a watchlist is in how you read the data from the composite, not in how you input it. Simplest is to do as I suggested. Just add in the prices and number to the composite and do the math of averaging when you use the composite
AB does have the watchlists stored in its database and checks this listing
If you have selected not to pad to a reference symbol in the AA Settings then if a symbol does not have data for a particular day it will not add anything to the composite. This is why adding 1 to the field helps in getting average fo what stocks were traded on that day
If you want to pad (say to an index that has data for every market day) it will add the last traded close price and a 1 to the composites
here is a simple example, I also use the name of the watchlist in the creation of the composites
Buy=1;//
if(InWatchList(0))
{
Comp = "~"+CategoryGetName(categoryWatchlist,0);
AddToComposite(C,Comp,"C");
AddToComposite(1,Comp,"I");
}
You can also loop through
for(w=0;w<63;w++)
{
if(InWatchList(w))
{
Comp = "~"+CategoryGetName(categoryWatchlist,w);
AddToComposite(C,Comp,"C");
AddToComposite(1,Comp,"I");
}
}
by selecting the composite symbol, here is the code for plotting
compavg = c/i;
plot(compavg,"Group Avg Price",colorgreen,styleline);
you can also do this for groups, industries or sectors etc
--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm
__._,_.___
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
SPONSORED LINKS
| Investment management software | Real estate investment software | Investment property software |
| Software support | Real estate investment analysis software |
YAHOO! GROUPS LINKS
- Visit your group "amibroker" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___
