Cleanup multiple Watchlist (before an exploration)

with this code (below) all symbol in watchlist 10 are erased BEFORE an exploration.

Question: If I want erase multiple watchlists (example wl10, wl15 and wl30), how I can modify the code?

listnum =  10;

if ( Status( "stocknum" ) == 0 )
{
    oldlist = CategoryGetSymbols( categoryWatchlist, listnum );
    for ( i = 0; ( sym = StrExtract( oldlist, i ) ) != ""; i++ )
    {
        CategoryRemoveSymbol( sym, categoryWatchlist, listnum );
    }
}
...
...
...

thanks in advance for any help.

@kiss1170, for example, you can use an additional loop with a "list" of watchlists coded in string:


if( Status( "stocknum" ) == 0 )
{
    lists =  "8,9,10, 22";

    for( j = 0; ( str_listnum = StrExtract( lists, j ) ) != ""; j++ )
    {
        listnum = StrToNum( str_listnum );
        oldlist = CategoryGetSymbols( categoryWatchlist, listnum );

        for( i = 0; ( sym = StrExtract( oldlist, i ) ) != ""; i++ )
        {
            CategoryRemoveSymbol( sym, categoryWatchlist, listnum );
        }
    }
}

1 Like

Thank Beppe.... it's perfect.
Sempe gentilissimo.. Grazie

2 Likes