Number of symbols in back test

Hi 'brokers,

I know how to get the number of symbols in a watch list When I name the watch list in an AFL script. What I'd like is the number of symbols in the default list a rotational back test is using so I can figure percentile ranks, cut offs and the like.

Stay safe,


There isn't a default list.
The list is set by user and it may be differ depending on what was set last time (if analysis not being saved as project file).

You possibly mean how to get the watchlist number set in Filter window - Include of analysis toolbar (?)
If so then you can get it via GetOption function.

wlnum = GetOption("FilterIncludeWatchlist");//WL number of Filter window - Include 
watchlist = CategoryGetSymbols(categoryWatchlist, wlnum);
symcount = StrCount(watchlist , "," ) + 1;

Yeah, that's exactly what I meant. Brilliant!

Thanks so much,

  John Bollinger

I should clarify for future readers. What I was trying to get was a handle for the currently selected watch list so I could count the number of symbols in it. fxshrat's answer is correct.

1 Like

@BBands yes thanks for clarifying your intention. I had posted and deleted a suggestion when it became clear that was your intention. But I also stumbled across a code that I did not think should work to count the number of symbols in a WL that is named in the afl script,

So I thought you may have intended this type of WL creation,

// in AA window, does it mater in the "Apply to *Filter" what is selected?


nETFlist = StrCount( ETFlist, "," ) + 1; 

Filter = Status("LastBarInRange") AND Status( "stocknum" ) == 0;
AddColumn(DateTime(), "Date", formatDateTime);

AddColumn(nETFlist, "# tickers in ETF list");

And when I run an exploration on a WL that contains none of those symbols, I thought it would not work. And yet it appears to work (and this opens up a range of possibilities when writing codes using multiple watch lists).

Here run against the DJIA, a 30 stock WL that does not contain any of the ETF's from my "ETFlist"

No, it does not matter what is set in Filter of analysis window.
Your variables are independent code lines (independent from Analysis Filter). nETFlist just calls ETFlist string variable to count number of its commas. That's all it does. So unsurprisingly nETFlist returns 11.

1 Like

Learned something about status from that. Thanks.