I know how to create a watchlist based on another watchlist and also I know how to create text files from a watchlist but I don't know (not much programming experience) how to update a watchlist with symbols available in text files on the hard drive (for example in C:\data there are files like aapl.txt, amzn.txt, nflx.txt, etc.) but the files may change daily and I want the watchlist updated based on new ones only.)
Any help will be appreciated. I search this forum and I could not find the answer. Maybe I missed it.
I tried a few different things but did not work. I need to important text files from hard drive to a watchlist after cleaning it. The text files have the symbol name and extension .txt, e.g. AAPL.txt
I need to do this daily because the files on hard drive change. Thanks in advance.
I know how to import any files manually to a watchlist. I have been doing that all along. I am looking for code that will do that automatically that is not available in that link.
Use fdir with CategoryAddSymbol, then create Batch to clear symbols from x watchlist (using batch 'Clear watch list' command) and to run script to populate x watchlist.
Note that watch lists files (those inside "Watchlists" subfolder) are read ONCE when you open database and saved ONCE when you close the database (or exit program). During all time in between they are kept in RAM.
The watchlist 10 is cleaned but it does not refresh. Is there a command to refresh watchlist (maybe close the file)?
Although I get the correct files in the interpretation window, watchlist is not populated. Maybe there is some command to close the file and reopen before populating.
BTW I run this from Apply in AFL Formula Editor. Is there another way to run it which is faster?
Is your "CategoryAddSymbol" grabbing the extension (.txt or .csv) of the file as well? Should it just be the symbol?
Also, would you need to shut down and restart AmiBroker to recognize the changes you made in the Watchlist?
Thanks to you and Tomasz I have solved part of problem. Files on hard drive have .txt extension and I eliminate that with script before I import to watchlist.
But now I have a more serious problem. In the watchlist I import from hard drive the symbols have no dividend adjustments, i.e., I need the data without dividend adjustment and only splits where it applies.
But since those same symbols already exist in the database as dividend adjusted, the new watchlist reverts back to them.
I tried to import the file to the watchlist with a modified name but it did not work. Probably they must be added to database first but I cannot find a way or function that does that.