// we run the code on WatchList 0
List = CategoryGetSymbols( categoryWatchlist, 0 );
SetOption("MaxOpenPositions", 3);
if ( Status("stocknum") == 0 ) // Generate ranking when we are on the very first symbol
{
StaticVarRemove( "values*" );
for ( n = 0; ( Symbol = StrExtract( List, n ) ) != ""; n++ )
{
SetForeign ( symbol );
// value used for scoring
values = ROC(C,10);
RestorePriceArrays();
StaticVarSet ( "values" + symbol, values );
_TRACE( symbol );
}
StaticVarGenerateRanks( "rank", "values", 0, 1224 );
}
symbol = Name();
values = StaticVarGet ( "values" + symbol );
rank = StaticVarGet ( "rankvalues" + symbol );
BuySignal = “enter buy condition here” AND rank <=10;
// buy on next bar
Buy = Ref(BuySignal,-1);
PositionScore = mtRandom();
Of course this doesn’t guarantee a trade. It could be that top ranked items don’t meet your buy condition.