CategoryRemoveSymbol - how to remove not tradeable symbols from watchlist

I have a large watchlist (US ETFs), where many of the entries I identify as not tradeable.
I then want to process the tradeable ones, for my trades. I am doing some of this in CBT.
So I want to remove the currently not tradeable symbols from the watchlist to reduce processing time.
The code I have to do this is as follows.
However, it does not work as I expect, in that when I subsequently process the same Symbol loop List, the not tradable symbols are still there.
Can you please advise what I am doing wrong?

	List = 0;  
	if( GetOption( "ApplyTo" ) == 2 ) 								// Get symbols in watchlist  
		wlnum = GetOption( "FilterIncludeWatchlist" );   
		List = CategoryGetSymbols( categoryWatchlist, wlnum ) ; 
	if( GetOption( "ApplyTo" ) == 0 )   
		List = CategoryGetSymbols( categoryAll, 0 );   
		Error( "The formula works fine if your ApplyTo setting is 'Filter' or 'All' " );   
	for ( n = 0; ( Symbol = StrExtract( List, n ) )  != "";  n++    ) 				// Remove symbols where last bar is not tradeable from the symbol list to speed up processing.
		TradeableSy	= StaticVarGet("Tradeable"+ Symbol ); 
		if( LastValue(TradeableSy) != 1 ) CategoryRemoveSymbol( "", categoryWatchlist, wlnum);

Your call to CategoryRemoveSymbol() doesn't pass the symbol name. You're passing an empty string instead, so of course nothing gets removed.

1 Like

Thank you for your response.
I understand from the documentation that the double quote will result in the current symbol being used. I have rerun my tests with:

CategoryRemoveSymbol( "Symbol", categoryWatchlist, wlnum);

and the result is the same. Nothing is removed from the watchlist.

Should be:

if( LastValue(TradeableSy) != 1 ) CategoryRemoveSymbol( symbol, categoryWatchlist, wlnum);

In the CBT, the current symbol is ~~~Equity. As @PeterD pointed out, you should not put quotes around the variable name symbol.

Thank you, That was one option I did not try.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.