Adding and removing stocks from watchlist in one click

Is it possible to create buttons for adding and removing stocks from a particular watchlist. For e.g. I have a watchlist "Open positions" and once I close the trades, I remove from the "Open positions" watchlist and add them to "Closed positions' watchlist for my tracking and review.

If this can be done in a one-click whereby I press a particular (GUI?) button, it removes from "Open positions" watchlist and adds to "Closed positions" watchlist, it would be great. My question to experienced members is that - is this possible using GUI controls? If GUI controls are not the best solution, please point me in the right direction and I'll code this in AFL. Thanks.

P.S. I am using Amibroker Pro 6.2.1

@applet, you don't need Gui Buttons. See here:

You can easily assign custom keyboard shortcuts for such tasks. With ctrl key pressed you can select/deselect multiple symbols and add or remove them in one go:

Exactly the same question has been already asked and answered here, so it's always good to start from searching the forum ...

2 Likes

Thanks. I came across this post, however, it doesn't address the solution to my idea where in one click I want to move stocks from one watch-list "open positions" to another watch-list "closed positions".

@applet I suggested trying the simplest solution first, because it works for me very well. No coding required at all.

Remember that if you want to easily select all stocks from a watchlist you can just click one of them in the Symbols window and press ctrl + A. In this way all stocks from a watchlist will be highlighted. No matter if there are 5, 10 or 100 stocks in that watchlist. If you want to highlight only first five stocks (or any 5 stocks in a row) - click the first one, press and hold Shift and click the fifth one - all five will be highlighted. Then simply use a keyboard shortcut and all (or selected) stocks will be added to a different watchlist or removed. I understand that this is not exactly a "one click" solution but it requires not more than a few clicks or a few seconds to complete the whole process.

Of course there are other ways of achieving the same result. For instance:

  1. Using Assignments organizer, you can move all or selected issues from one watchlist to another one in one go. https://www.amibroker.com/guide/w_organizer.html

1

  1. In AB 6.31 two new commands were introduced to improve Batch functionality which you can use:
  • Batch: add "add results to watchlist" action / WatchlistAddResults
  • Batch: add "clear watchlist" action / WatchlistClear

http://www.amibroker.com/devlog/wp-content/uploads/2019/08/readme6310.html

  1. Of course, if you want, you can add, modify or clear watchlists programmatically (directly from the formula) using: CategoryAddSymbol() , CategoryRemoveSymbol() , CategoryGetSymbols()

Whether it is a Gui Button or ParamTrigger (or anything else) to run such code, depends on you. You can also make it happen automatically - every time you run an Exploration, Scan etc. You can also add the results to a watchlist in specific order - see examples:

5 Likes

Thanks @Milosz - much appreciated. Assignment organizer does the job and is exactly what I was looking for.

1 Like

Milosz wrote a nice piece. I’d agree that hotkeys the way to go. Amazing how you can speed up your process in Amibroker with very easy to customize hotkeys. My common are ctrl-a for watchlist, Ctrl-f for favourites, use that for throwing interesting charts into favorited before making it to watchlist.

Ctrl-d/w/m for daily weekly monthly charts. Alt-q for bars, alt-w for candles.

I find a keyboard a efficient tool to get work done, mouse is more of a pain to move your hand over just to click something.

3 Likes