Watch lists in scan


I have several afl scripts that use watch lists, some do exports, some calculate indices, etc... I run them in a 'new analysis' window by selecting a formula, using 'apply to filter', then selecting a watch list and scanning.

My questions:

  1. I would like to be able to name the watch list in the script. How can I do that?
  2. I do these each day and would like to automate these tasks as much as possible. In general what is the best way to do this in a routine manner?

I've included an example script below. Comments on it and pointers to tutorial material gratefully accepted.


/* New Analysis, select watch list, scan */

/* required by scan mode */
Buy = Sell = Short = Cover = 0.0;
Filter = 1.0; 

/* index symbol */
symbol = "~FAANG";

/* Get a data point to normalize with. */
startDate = "2012-05-18";
startVal = Lookup(Close, _DT(startDate), -1);

/* add data to our index OHLCV fields */
AddToComposite(Open / startVal * 100, symbol, "O" );
AddToComposite(High / startVal * 100, symbol, "H" );
AddToComposite(Low / startVal * 100, symbol, "L" );
AddToComposite(Close / startVal * 100, symbol, "C" );
AddToComposite(Volume, symbol, "V" );

/* Use the open interest field as a counter. */
AddToComposite( 1, symbol, "I" );

/* Create our Index */
graph0 = Foreign( symbol, "X" ) / Foreign( symbol, "I" );

/* That's all folks! */
  1. In your case you do not need to name WL in AFL as you can save your analysis to project file (.apx file extension) which saves all of your analysis settings plus your AFL. So besides other settings each project file would have different watchlist of your choice being saved. No code required.

  2. Then in order to run one or multiple projects or tasks automated use batch feature including AmiBroker's internal task scheduler.


Perfect. You are the man, thanks so much!

Happy holidays to all,