--------------------
// watchlist should contain all symbols included in the test
wlnum = GetOption( "FilterIncludeWatchlist" );
List = CategoryGetSymbols( categoryWatchlist, wlnum ) ;
if( Status( "stocknum" ) == 0 )
{
// cleanup variables created in previous runs (if any)
StaticVarRemove( "rank*" );
StaticVarRemove( "values*" );
categoryList = ",";
for( n = 0; ( Symbol = StrExtract( List, n ) ) != ""; n++ )
{
SetForeign( symbol );
// use sectors for ranking
category = sectorID();
// add sector to the list
if( ! StrFind( categoryList, "," + category + "," ) ) categoryList += NumToStr( category, 1, 0 ) + ",";
// write our ranking criteria to a variable
// in this example we will use 10-bar rate-of-change
values = C;
RestorePriceArrays();
// write ranked values to a static variable
StaticVarSet( "values" + category + "_" + symbol, values );
}
// generate separate ranks for each category from the list
for( i = 1; ( category = StrExtract( categoryList, i ) ) != ""; i++ )
{
StaticVarGenerateRanks( "rank", "values" + category + "_", 0, 1224 ) ;
}
}
CategoryAddSymbol( "", categoryWatchlist, 3 );
category = sectorID();
symbol = Name();
m = Month();
values = StaticVarGet( "values" + category + "_" + symbol );
rank = StaticVarGet( "rank" + "values" + category + "_" + symbol );
// exploration code for verification
AddColumn( values, "values" );
AddColumn( rank, "rank" );
Filter = rank <= 200;
if( Status( "Action" ) == actionExplore )
SetSortColumns( 3 );
---------------------------