PureBytes Links
Trading Reference Links
|
Ken,
This is where Composite Symbols come in handy.
First you would have a scan that created a composite symbol for the Watchlist (or other grouping) that you are intersted in. This composite symbol would be a standard composite symbol containing an array of data which is the count of symbols in the watchlist for that day.
Second, you would create your averages, but would divide the averages by the number of symbols in the watchlist on a given day.
So, let's say that you had at most three days worth of data - Monday, Tuesday and Wednesday for the symbols in your watchlist called "MyBiggies". On Monday, you had 10 symbols with data. Your count for Monday woudl be 10. On Tuesday, one company stopped trading, so you had 9 symbols with data. Your count for Tuesday would be 9. On Wednesday, another company stopped trading, so now you are down to 8 symbols with data.
When you created the Composite Symbol containing the count of symbols in your MyBiggies watchlist, you would see that the data for Monday, Tuesday, and Wednesday would be: 10, 9 and 8.
When you create your averages, you would divide by the count of symbols on that day. Assuming that the sum of the prices in your watchlist was $100 for Monday, $90 on Tuesday, and $80 on Wednesday, your average value for these days would be:
Monday = $100/10 = $10
Tuesday = $90/9 = $10
Wednesday = $80/8 = $10
This is an example for illustrative purposes. This is essentially my process for normalization, except that I divide the individual symbol prices by the count in their grouping and then sum the divided prices. (It's easier that way.)
I hope this helps.
Regards,
Dan.
-------------- Original message --------------
From: "Ken Close" <ken45140@xxxxxxxxx>
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
|