Herman, I have found various ways to accomplish things similar to these, but I do not thing all of these will work from within AFL. At least, I don't know how to do them. So, for example, to erase what is already in, say, watchlist 19, 20 and 21, I've created this .js file (I attach the text below) that calls some .afl. You will notice that this code is very very similar to that posted by Tomasz on www.amibroker.com in the first place. I have not tried to do precisely the things you've asked for, but if its possible, I imagine you could start with this codebase and modify by using http://www.amibroker..com/guide/objects.html. You can also find more stuff at http://www.google.com/search?hl=en&q=site%3Awww..amibroker.com+AB.analysis . FWIW, I use this script below every night and then using .afl I populate these 3 watchlists with new tickers that meet criteria I like. Hope this helps.
remove.js
/********************Amibroker open to database***********************/
AB = new ActiveXObject("Broker.Application");
AB.LoadDatabase("C:\\Program Files\\Amibroker\\Big");
AB.Visible = true;
/* retrieve automatic analysis object */
AA = AB.Analysis;
/* load formula from external file */
AA.LoadFormula("Formulas\\Custom\\Yahoo Fundamentals\\remove stocks from watchlist 19 - 21.afl");
// AA.LoadSettings("the_path_to_the_settings_file.abs");
AA.ClearFilters();
//AA.Filter( 0, "market" ) = 0;
// uncomment line below to
AA.Filter( 0, "watchlist" ) = 21; // include WL 21
/* set apply to and range */
AA.ApplyTo = 2; // use filters
AA.RangeMode = 1; // use all available quotes
AA.RangeN = 1;
/* run explore and display report */
AA.Scan();
/********************Amibroker Save Database***********************/
AB.SaveDatabase();
/********************Amibroker Save Database (end)***********************/
AB.Quit();
//AQ.Quit();
remove stocks from watchlist 19 - 21.afl
************************************************************************
//removes all tickers in a watchlist 19 to 21
Filter=1;
AddColumn(C,"c",1.2);
Buy=Sell=Cover=Short=0;
for( wl = 19; wl < 22; wl++ )
if(InWatchList(wl))
{
CategoryRemoveSymbol( "", categoryWatchlist, wl );
}
----- Original Message -----
From: Herman
To: AmiBroker User Group
Sent: Wednesday, June 18, 2008 6:57 AM
Subject: [amibroker] Working with Watchlists from AFL
Can someone point me to help/links on AFL programming with WatchLists? I can't seem to find much info about it anywhere. Is it possible to:
1) create WatchLists by name from AFL?
2) delete WatchLists by name from AFL?
3) and if so, how do I protect myself from overwriting an existing WL?
4) When creating a WatchList do I need to update the WL index file?
5) Can I create GLOBAL WatchLists?
Are there any simple solutions for these tasks? I could write some complicated work-arounds but I don't want to waste a lot of time if a simple solution is available.
Many thanks,
herman
|