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

RE: [amibroker] New Question on Watchlist Averages



PureBytes Links

Trading Reference Links

Tomasz: thanks for the suggestion but I do not know how to implement using
the AddtoComposite over ALL symbols and have just the ones I want appear in
their own composites representing different industries.
 
I have read and reread the help files, the pdf on ATCs and have searched
past messages on all sorts of terms and this just does not come out where I
understand it.
 
To scan over all symbols and use regular ATC just against the symbols in
each grouping (watchlist), I thought about this kind of code but just do not
believe it will work.
 
if (InWatchList(11))
 {
  AddToComposite(C,"~Z01Aerospace_Defense","c");
  AddToComposite(1,"~Z01Count","X");
 }
if(InWatchList(12))
 {
  AddToComposite(C,"~Z02Automotive","c");
  AddToComposite(1,"~Z02Count","X");
 }

etc....
 
Any other ideas on this approach?
 
Off to tackle jscript automation along lines suggested by Dan.
 
Ken

  _____  

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Tomasz Janeczko
Sent: Wednesday, August 09, 2006 3:14 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] New Question on Watchlist Averages


Hello,
 
You would need to check for Null values and/or use Nz (null to zero) because
of the fact
that if you don't have data for particular security Foreign() will give you
null values at the beginning of the array.
 
Personally I would advice using AddToComposite in a regular way (scan over
entire database).
This way you would arrive to correct results faster and with less code. This
is so because plain scan
with addtocomposite does not involve any loops therefore it is fast even if
larger number of symbols is
being analysed. Especially once your needs grow over time and you will want
to calculate averages
not only for few watchlists but also for some industry groups, etc.

Best regards,
Tomasz Janeczko
amibroker.com

----- Original Message ----- 
From: Ken Close <mailto:ken45140@xxxxxxxxx>  
To: amibroker@xxxxxxxxxxxxxxx 
Sent: Wednesday, August 09, 2006 8:44 PM
Subject: [amibroker] New Question on Watchlist Averages

I have been making some progress using this code, I think from the help
files and/or mentioned here on the list:
 
function CreateAverageForWatchList( listnum )
{
   // retrive comma-separated list of symbols in watch list
   list = CategoryGetSymbols( categoryWatchlist, listnum );
 
   Average = 0; // just in case there are no watch list members
 
   for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
   {
      f = Foreign( sym, "C" );
      if( i == 0 ) Average = f;
      else Average = Average + f;
   }
   return Average / i; // divide by number of components
}

I am creating averages of various watchlists and it is working....except
for.....
 
The resulting average is no longer than the watchlist member with the least
or shortest amount of data.
If I have 20 members, 19 of which have data going back into the early 90s
but 1 member has data for the last 6 months, then the average which is
created is only 6 months long.
 
Is there any modification to the above code such that an average for each
date will be created from which ever members have data for that date.  In my
example, I would get an average based on 19 members up until 6 months ago
whereupon the average would be based on 20 members.
 
Can this code do that? If not, how could the code be altered to accomplish
that.
 
Thanks to all who are trying to help me with this. Some of the other
suggested approaches, using jscript (thanks Dan), etc, have been a little
daunting and I was able to get the above to work until I discovered the
truncated data (shortened average to the shortest list member).
 
Ken