Hi,
I am trying to rank a watchlist using StaticVarGenerateRanks. I know this has been extensively covered on the forum, but am having a small issue I can't resolve. I am using the following code, which works perfectly in most situations.
wlnum = GetOption( "FilterIncludeWatchlist" );
List = CategoryGetSymbols( categoryWatchlist, wlnum ) ;
if ( Status("stocknum") == 0 )
{
StaticVarRemove( "values*" );
for ( n = 0; ( Symbol = StrExtract( List, n ) ) != ""; n++ )
{
SetForeign ( symbol );
values = Close * MA(Volume, 20);//GetFnData( "SharesOut" );
RestorePriceArrays();
StaticVarSet ( "values" + symbol, values );
_TRACE( symbol );
}
StaticVarGenerateRanks( "rank", "values", 0, 1224 );
}
symbol = Name();
MarketCap = StaticVarGet ( "values" + symbol );
rank = StaticVarGet ( "rankvalues" + symbol );
Filter = 1;
AddColumn ( MarketCap, "MarketCap", 1.0 );
AddColumn ( rank, "rank", 1.0);
SetSortColumns( 4 );
The exception is when running it on a historical date that precedes the first trading date for the first symbol in the watchlist. Evidently this relates to the line
if ( Status("stocknum") == 0 )
If the first symbol in the watchlist doesn't exist on the specified date no static variables or rankings are generated for the other symbols that do have data on that date.
Something tells me there must be an obvious/easy fix so that I can generate ranks for whichever symbols in the watchlist do have data for a specified date, but nothing I have tried has worked so I would appreciate any assistance.
Thanks
Dan