How to copy and rename Watchlist Symbols

For various reasons (order placing, OCAGroup forming, etc.) I would like the Explorer to process symbols top down as they appear in the Watchlist. Tomasz explained in this post why this is not done:

Failing to obtain sequential processing would lead to a major rework of my code and probably means porting it to an Indicator. The simplest solution seems to set maxthreads=1, select only one watchlist in the AA Filter, and copy the symbols while adding an alpha prefix to the symbol name. The explorer would then sort by the prefix and processing would be top down.

I have been unsuccessful finding a copy/rename symbol example. The nearest solution I could find was (see code below):
however, this code doesn't copy and it renames all symbols in the database.

I want to copy/rename only the symbols in one watchlist. Anyone seen code that does this?

Many thanks for any ideas or help you can give!

Maybe you could do a simple exploration to backfill your watchlist,
and than another explorer using

if (Status("stocknum") == 0)
 //process in order

Hello Herman,

In my opinion changing Symbols' names just to achieve sequential processing in some custom order, is not the best idea. I would opt for porting the whole solution (or at least some part of it) to an Indicator. In case of the Indicator, sequential execution is guaranteed and you can perform all operations in a fully customizable order. For example:



WatchlistName = "TopPicks";
WatchlistNumber = CategoryFind( WatchlistName, categoryWatchlist );
SymList = CategoryGetSymbols( categoryWatchlist, WatchlistNumber );

Then you could easily iterate through the list of symbols and perform all the operations you need:

for( i = 0; ( symbol = StrExtract( SymList, i ) ) != ""; i++ )
  // body of the loop
  _TRACE("Symbol is " + symbol );


Thank you, that would be a nice solution.

Meanwhile, I just realized that I can use the AddToComposite() to copy symbols to a name with the WL Index prefixed. I can delete old composites and create new composites in a small loop when Stocknum == 0.

I will try that first, it might be the only thing I have to add to the code. That would be a simple solution! I would strip the prefix when placing orders.

Anyone see any problems with that?

Thank so much for your suggestion!

Another alternative would be first you do an exploration saving in a text file your instructions, than in the in second exploration using stocknum == 0 you process only the text file with your instructions

AFAIU, your only issue is the order of exploration output. Right? If that is case then you don't need indicator mode but still can use explorer. Also there are not text files required. And no symbol change and no ATC.

Just use CategoryGetSymbols() and use AddRow() for output. If you want to output further data for each symbol then store it to matrix (and again output via AddRow).

The code being used for below sample result output has just some 30 to 40 lines so it is no rocket science (And no, not multiple lines of AddRow but just one line of AddRow have been used). As you can see explorer symbol order matches symbol order of WL.


Thanks, everyone! It was very helpful to see the different ideas.

I have the basics working using ATCs. Just a small loop that executes at StockNum==0 to create composites with the WL index prefixed to the symbol name and copy them to a watchlist. There was no need to make any changes to the main code. However, I still have to perform two explorations and manually switch watchlists in the filter. One explore would be nice but that solution is for another day.

Happy coding!