{"id":1258,"date":"2016-01-24T07:26:18","date_gmt":"2016-01-24T12:26:18","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=1258"},"modified":"2016-01-28T07:34:58","modified_gmt":"2016-01-28T12:34:58","slug":"how-to-count-symbols-in-given-category","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2016\/01\/24\/how-to-count-symbols-in-given-category\/","title":{"rendered":"How to count symbols in given category"},"content":{"rendered":"

When we want to find out how many symbols belong to given category (such as watchlist) then for manual inspection, it is enough to hover the mouse cursor over the particular category name in the Symbols window and the information will be shown in a tooltip:<\/p>

\"Category<\/p>

If we want to check such information using AFL code, we could read the list of symbols returned with CategoryGetSymbols<\/a> and by counting commas (which separate symbol names) find out the number of tickers.<\/p>

A reusable function is presented below:<\/p><\/span>function <\/span>CategoryCountSymbols<\/span>( <\/span>category<\/span>, <\/span>number <\/span>)
{
   <\/span>count <\/span>= <\/span>StrCount<\/span>( list = <\/span>CategoryGetSymbols<\/span>( <\/span>category<\/span>, <\/span>number <\/span>), <\/span>","<\/span>);
   return <\/span>IIf<\/span>( list == <\/span>""<\/span>, <\/span>0<\/span>, <\/span>count <\/span>+ <\/span>1 <\/span>);
}    

<\/span>Title <\/span>= <\/span>"Symbols in watchlist 0: " <\/span>+ <\/span>CategoryCountSymbols<\/span>( <\/span>categoryWatchlist<\/span>, <\/span>0 <\/span>)<\/code>","protected":false},"excerpt":{"rendered":"

When we want to find out how many symbols belong to given category (such as watchlist) then for manual inspection, it is enough to hover the mouse cursor over the particular category name in the Symbols window and the information will be shown in a tooltip:If we want to check such information using AFL code, […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,5],"tags":[53,64],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1258"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=1258"}],"version-history":[{"count":2,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1258\/revisions"}],"predecessor-version":[{"id":1261,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1258\/revisions\/1261"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=1258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=1258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=1258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}