Hi Dan,
Thanks for the script. I will be very busy the next few days and may have
a ton of “honey-do’s” to perform on the weekend so it may
take a while for me to get to trying out the code.
My current needs are to run about 5
explorations with unique parameters and have the results put into watchlists. The
code below seems easy enough for me to understand how to modify it to perform
these basic tasks.
Thanks once again.
Dave
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Dan Clark
Sent: Wednesday, March 15, 2006
8:06 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker]
Automating AA results handling (w/o Batman)
Dave,
Here is a Jscript that I use to run AFL
scripts one after another. To be precise, it’s actually a
hacked up version of what I use. (My “production”
script does logging and some error checking). It shows how
scans and explorations can be chained together. It loads each AFL
and its associated parameters and then executes the AFL.
To execute multiple AFL scripts, just run
the AFL scripts one after another like I have here. If you wanted to be
slick, you could instantiate the Broker.Application and Analysis once and then
loop through changing the parameters.
You would need to edit this to your
parameters (paths, files and other parameter settings) and then save it to a
file in the ..\Scripts folder. The file should have a “.js”
extension.
You can call this Jscript file from the AB
Tools Menu or you can schedule it to run using the Windows Scheduler.
Regards,
Dan.
/* create AB
object */
AB = new
ActiveXObject("Broker.Application");
/* retrieve
automatic analysis object */
AA = AB.Analysis;
/* load formula
from external file */
AA.LoadFormula("C:\\Program
Files\\AmiBroker\\Formulas\\Systems_DailyScans\\A1_QPATCIndexes_Count.afl")
/* setup filters
*/
/* backtest over symbols
present in market 0 only (zero-based number) */
AA.ClearFilters();
/* set apply to
and range */
AA.ApplyTo = 0;
// use symbols
AA.RangeMode = 2;
// use last day's quotes
AA.RangeN = 1;
/* run Scan */
AA.Explore();
/* create AB
object */
AB = new
ActiveXObject("Broker.Application");
/* retrieve
automatic analysis object */
AA = AB.Analysis;
/* load formula
from external file */
AA.LoadFormula("C:\\Program
Files\\AmiBroker\\Formulas\\Systems_DailyScans\\A2_QPAddCompositeIndexes7.afl")
/* setup filters
*/
/* backtest over
symbols present in market 0 only (zero-based number) */
AA.ClearFilters();
/* set apply to
and range */
AA.ApplyTo = 0;
// use symbols
AA.RangeMode = 2;
// use last day's quotes
AA.RangeN = 1;
/* run Scan */
AA.Explore();
/* create AB
object */
AB = new
ActiveXObject("Broker.Application");
/* retrieve
automatic analysis object */
AA = AB.Analysis;
/* load formula
from external file */
AA.LoadFormula("C:\\Program
Files\\AmiBroker\\Formulas\\Systems_DailyScans\\B_QPAddIndexRelativeStrength.afl")
/* setup filters
*/
/* backtest over
symbols present in market 0 only (zero-based number) */
AA.ClearFilters();
AA.Filter( 0,
"watchlist" ) = 49;
/* set apply to
and range */
AA.ApplyTo = 2;
// use filters
AA.RangeMode = 2;
// use last day's quotes
AA.RangeN = 1;
/* run backtest
and display report */
AA.Scan();
/* create AB
object */
AB = new
ActiveXObject("Broker.Application");
/* retrieve
automatic analysis object */
AA = AB.Analysis;
/* load formula
from external file */
AA.LoadFormula("C:\\Program
Files\\AmiBroker\\Formulas\\Systems_DailyScans\\C_QPAddIndexRank.afl")
/* setup filters
*/
/* backtest over
symbols present in market 0 only (zero-based number) */
AA.ClearFilters();
AA.Filter( 0,
"watchlist" ) = 48;
/* set apply to
and range */
AA.ApplyTo = 2;
// use filters
AA.RangeMode = 2;
// use last day's quotes
AA.RangeN = 1;
/* run backtest
and display report */
AA.Scan();
/* create AB
object */
AB = new
ActiveXObject("Broker.Application");
/* retrieve
automatic analysis object */
AA = AB.Analysis;
/* load formula
from external file */
AA.LoadFormula("C:\\Program
Files\\AmiBroker\\Formulas\\Systems_DailyScans\\G_CMFAndOBVToPriceLRDvrg_WLongTrend.afl")
/* setup filters
*/
/* backtest over symbols
present in market 0 only (zero-based number) */
AA.ClearFilters();
AA.Filter( 0,
"watchlist" ) = 1;
/* set apply to
and range */
AA.ApplyTo = 2;
// use filters
AA.RangeMode = 2;
// use last day's quotes
AA.RangeN = 1;
/* run backtest
and display report */
AA.Explore();
AB.SaveDatabase();
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of MarketMonk777
Sent: Tuesday, March 14, 2006 9:54
PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker]
Automating AA results handling (w/o Batman)
Hi Dan,
Thanks for the code below. You
wouldn’t happen to have any scripts that will automatically run a number
of AAs in a batch mode do you?
Dave
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Dan Clark
Sent: Tuesday, March 14, 2006 8:26
PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker]
Automating AA results handling (w/o Batman)
Brian,
Add this at the top:
CategoryRemoveSymbol("", categoryWatchlist,
1); //Watchlist = 1
…
//Some criteria code
…
//Add Symbols to Watchlist 1
if (bCriteriaIsMet)
CategoryAddSymbol( "" , categoryWatchlist,
1); //Watchlist = 1
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Brian
Sent: Tuesday, March 14, 2006 8:17
PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Automating AA
results handling (w/o Batman)
I used to have a small script
that would automatically take
exploration results and put them in a specific
watchlist. I have
looked at Batman but I think that might be
overkill for what I need.
Only other functionality that would be nice is
such a script would be
to automatically delete the contents of the
watchlist prior to
repopulating it.
Anyone got this script handy? Mine got lost in the
shuffle awhile back.
Thanks in advance!
Brian
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
YAHOO! GROUPS LINKS