# Problems with ranking code

Hello,

I should appreciate it if someone would help me with the following simple code for ranking.

``````WatchList  = GetOption("FilterIncludeWatchlist");
List       = GetCategorySymbols(categoryWatchlist, WatchList);

if (Status("Stocknum") == 0 )
{
StaticVarRemove("Score*" );
for (n = 0;(Symbol = StrExtract(List, n)) != ""; n++)
{
SetForeign (Symbol);
REMA    = Ref(EMA(Close, 8), -1);
RROC    = ROC(Close, 6);
RScore  = Max(0, IIf(Low <= REMA, 0, RROC));
RestorePriceArrays();
StaticVarSet ("Score" + Symbol, RScore);
}
StaticVarGenerateRanks("Ranking","Score", 0, 1224);
}

Symbol    = Name();
Score     = StaticVarGet ("Score" + Symbol);
Ranking   = StaticVarGet ("RankingScore" + Symbol);

Filter = 1;
``````

I can not get any result from it. Probably the error is quite obvious, but I am unable to find it. Best regards.

@jptrader, it is strange. I tried the code you posted, that seems correct, and my Exploration was showing results also in the SymbolScore and SymbolRanking columns.
The only situation where I got some "empty" values was when I used a database with a lot of inconsistent data (I mean where some symbols had different ranges of bars and multiple unaligned data holes). But I suppose that this is not your case.

Additional information that you can provide us: Are you using an EOD data or some mixed data / real-time data (and in such a case data provider/plugin)?
What is the Analysis periodicity you are using for the Exploration?
Which version of AmiBroker are you using?

Let's see if anyone else can reproduce your problem. And just to be sure, is the code posted EXACTLY the one that you used to generate the screenshot?

Simply output the BarCount and Interval in Explorer (see below code addition). Then you will have more information in front of you.

Also if you have enabled Pad&align of analysis settings - General tab then make sure that the symbol the data is aligned to has enough data itself. If that symbol has inappropriate Barcount then you may get empty results for sure.
Note: if Pad&align is enabled then the BarCount of the reference symbol is used/shown. I.e. if the reference symbol has just one bar of data but the WL symbols all have e.g. 1000 bars then `Barcount` will be `1` but not `1000`.

``````WatchList  = GetOption("FilterIncludeWatchlist");
List       = GetCategorySymbols(categoryWatchlist, WatchList);

if (Status("Stocknum") == 0 )
{
StaticVarRemove("Score*" );
for (n = 0;(Symbol = StrExtract(List, n)) != ""; n++)
{
SetForeign (Symbol);
REMA    = Ref(EMA(Close, 8), -1);
RROC    = ROC(Close, 6);
RScore  = Max(0, IIf(Low <= REMA, 0, RROC));
RestorePriceArrays();
StaticVarSet ("Score" + Symbol, RScore);
}
StaticVarGenerateRanks("Ranking","Score", 0, 1224);
}

Symbol    = Name();
Score     = StaticVarGet ("Score" + Symbol);
Ranking   = StaticVarGet ("RankingScore" + Symbol);

Filter = 1;

``````

But then even if index has just one bar the SymbolRanking column would show ranking output (e.g. all 1) and wouldn't be empty.

So I think the actual reason for your NULL output seems to be wrong Filter setting.
E.g. WL and some Market is chosen and "Match any" being checked.
Then both your columns may result in being empty.
So clear Filter and make sure only Watchlist is chosen. And check "Match all".

1 Like

beppe, fxshrat,
{"ft_lang_label":"__label__en","ft_lang_prob":0.9053144,"math_prob":0.9474443,"size":1811,"snap":"2023-40-2023-50","text_gpt3_token_len":403,"char_repetition_ratio":0.10403985,"word_repetition_ratio":0.0,"special_character_ratio":0.21535063,"punctuation_ratio":0.09615385,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95848835,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-02T08:55:07Z\",\"WARC-Record-ID\":\"<urn:uuid:2d413822-e0e3-446d-8f5b-c007d0cb4923>\",\"Content-Length\":\"23971\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c4123824-4ae7-452a-8190-8fe7283dd904>\",\"WARC-Concurrent-To\":\"<urn:uuid:1ba07f35-1011-430d-9682-fe893edac9c4>\",\"WARC-IP-Address\":\"159.89.36.72\",\"WARC-Target-URI\":\"https://forum.amibroker.com/t/problems-with-ranking-code/19476\",\"WARC-Payload-Digest\":\"sha1:BMQXABNWK4L35CYHQVZR2K4GOBELQBUW\",\"WARC-Block-Digest\":\"sha1:LP56KRXOB7SROFUWLSTMYQWP74C65CRX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510983.45_warc_CC-MAIN-20231002064957-20231002094957-00396.warc.gz\"}"}