MM,
Sorry I wasn’t clear. I
was referring to Scan/Exploration versus embedding it in chart code.
Unless I’m misreading Jeff’s
code, if he runs this in a scan OR exploration, it will execute once for every
symbol in the source filter. Let’s assume:
1) That Jeff runs an exploration against Watchlist 1 and includes his
code below.
2) That Jeff’s Watchlist 1 has 10 symbols.
I’m not 100% sure, but I believe
that AB will iterate through the symbols in WL 1 and execute his code 10 times
(once for each symbol in WL 1). It’s executing 10 times
where once will be enough to remove the symbols.
I think a cleaner, simpler, faster
approach would be to create a simple Jscript that contained code for two AFL
explorations. The first AFL would be filtered so that it would execute
against only one symbol (to ensure that it runs once); it would include the
looping “Remove” Symbol code below. This would clean
out the target Watchlist.
Then Jscript would execute a second
AFL. The second AFL would have the “Add Symbol” (no loops)
code and would execute using whatever filter criteria you defined.
Below is a sample Jscript that will load
first one, then a second AFL script. You’d have to modify it,
of course, but it gives an idea of how to run AFL scripts from Jscript.
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\\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();
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of MarketMonk777
Sent: Sunday, March 26, 2006 12:53
PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] add scan
results to wathlist programmatically
Hi Dan,
Is there a difference? My
preference is to put it into all of my exploration code.
This is the beginning part (snippet) of
most of my explorations:
// -------- Parameter Conditions and Variables for
Exploration
WLF = ParamToggle ( "Add Results to a Watchlist?", "No|Yes") ;
// WLF – flag to select whether to add results to
watchlist or not
WLN
= Param("Set Watchlist Number", 2,
2, 60,1);
// WLN - sets the
watchlist number, but reserves the first 2 and last 4 watchlists
(I am using line
returns to force formatting in this email)
What I would like
to implement is the clearing of the watchlist should I set my WLF to true or
Yes. If I am to copy the results of this scan to my watchlist then I am going
to want to clear it first. The WLF will be true and the WLN will have the
watchlist # that I am going to use with this exploration. In the future I
am most likely going to hard code the watchlist # for each exploration.
This will make it easier to run batch processing via Batman or scripts (way
beyond my skill level at the moment though).
MM
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Dan Clark
Sent: Sunday, March 26, 2006 6:32
AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] add scan
results to wathlist programmatically
Jeff,
Are you going to run this in a scan or
exploration?
Regards,
Dan.
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of hongyu lu
Sent: Saturday, March 25, 2006
10:45 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] add scan
results to wathlist programmatically
thanks for all the info to
get it work. here is the summary for reference.
1. To clear watchlists:
function ClearWatchList(_watchListNumber) {
_toClear =
GetCategorySymbols(categoryWatchlist,
_watchListNumber);
for(i = 0; (symC = StrExtract(_toClear,
i) ) != ""; i++) {
CategoryRemoveSymbol(symC, categoryWatchlist,
_watchListNumber);
}
}
ClearWatchList(0);
ClearWatchList(1);
ClearWatchList(2);
ClearWatchList(3);
2. To add scanned out stocks to watchlists:
r2 = ConditionA and ConditionB;
if (LastValue(r2) == 1) {
CategoryAddSymbol("",
categoryWatchlist, 1);
}
Buy = 0;
Thanks again!
Jeff
On 3/25/06, Joe Landry < jelandry@xxxxxxxxxxxxx> wrote:
Here's another example. When you go
to see if you've been successful be sure to select refresh all
// clear Watchlists used to store
composite symbols of QP Sector Runs
WL =
3; // or use WL =
Param("WL No.",3,1,63,1);
ClearList =
GetCategorySymbols(categoryWatchlist, WL);
for( i = 0; ( symC = StrExtract(ClearList, i) ) !=
"";
i++ )
{
CategoryRemoveSymbol( symC, categoryWatchlist, WL );
}
Buy = Sell =0;
----- Original Message -----
Sent: Saturday, March 25,
2006 2:19 PM
Subject: Re: [amibroker] add
scan results to wathlist programmatically
could you give an example? I played with my afl but could not figure
out how to get the scanned out symbols.
if my buy signal is like below, how to add the scanned out 'buy'
symbols to watch list?
i tried: CategoryAddSymbol(Name(), categoryWatchlist, 10); but got all
db symbols added.
i also tried: valuewhen(buy, name()), but got syntax error.
could you shed some lite on this?
On 3/25/06, Joe Landry
<jelandry@xxxxxxxxxxxxx>
wrote:
There's a
function called categoryaddsymbol...can be used to add your selected ticker to
a watchlist to
build
watchlists. You can also clear your watchlist programmatically.
Best regards
----- Original Message -----
Sent: Saturday, March 25,
2006 1:04 AM
Subject: [amibroker] add scan
results to wathlist programmatically
is it possible to add scan results to wathlist with
AFL programmatically? I have to do "add all results to watch list"
all the time at this point.
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
YAHOO!
GROUPS LINKS
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
YAHOO!
GROUPS LINKS
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
YAHOO! GROUPS LINKS