I am simply trying to rank four symbols. AAPL, ABBV, INTC, MSFT
ABBV's data starts in 2013, where the rest of the symbols have decades of data. At the very beginning of ABBV's data, where it is collecting enough bars to build its score, I give it a temp score of -1000 as to simulate it being in last position score-wise. I do that with this:
values = Nz(values, -1000);
But during this time period, AB is giving it a rank of 1, which to me means in the first position. How can I tell it to give this symbol a rank of last during this time period? Something is not working right with this:
values = Nz(values, -1000);
Here is a graphic showing it:
And here is the score/rank generator script:
WatchlistNumber = 1; //64
myScoreSymbol = Name();
EnableTextOutput(0);
mySymList = CategoryGetSymbols( categoryWatchlist, WatchlistNumber, 0 );
EnableTextOutput(1);
SymbolCount = StrCount(mySymList, ",") + 1;
printf("Symbol SymbolCount: %g\n", SymbolCount );
FirstSymbol = Status("stocknum") == 0;
if( FirstSymbol ) // this must have data all the way back
{
// delete static variables
StaticVarRemove( "ItemScore*" );
// fill input static arrays
for ( i = 0; ( sym = StrExtract( mySymList, i ) ) != ""; i++ )
{
SetForeign( sym );
TimeFrameSet( inDaily ); // switch to daily time frame
values = ROC(Close, 20);
values = Nz(values, -1000);
TimeFrameRestore();
score = values;
// write ranked values to a static variable
StaticVarSet( "ItemScore" + sym, score );
}
// perform ranking
StaticVarGenerateRanks( "Rank", "ItemScore", 0, 1224 ); // normal rank mode
}
ThisScore = StaticVarGet("ItemScore" + myScoreSymbol );
Plot( ThisScore, myScoreSymbol + "_score", colorYellow );
printf( "ThisScore: " + NumToStr( ThisScore, 1.4 ) + "\n" );
And here is the rank-reader script:
WatchlistNumber = 1; //64
myScoreSymbol = Name();
EnableTextOutput(0);
mySymList = CategoryGetSymbols( categoryWatchlist, WatchlistNumber, 0 );
EnableTextOutput(1);
SymbolCount = StrCount(mySymList, ",") + 1;
printf("Symbol SymbolCount: %g\n", SymbolCount );
SymbolCount = SymbolCount -1;
// read ranking
ThisRank = StaticVarGet("RankItemScore" + myScoreSymbol ) ;
Plot( ThisRank , myScoreSymbol + "_rank", colorWhite );