iWatchList = 13;
Qty = AB.Stocks.Count;
for( i = 0; i < Qty; i++
)
{
Stk = AB.Stocks( i );
if( iWatchList < 1 )
{
if(
Stk.WatchListBits & ( 1 << iWatchList ) )
{
Doc = AB.Documents.Open( Stk.Ticker );
WScript.Sleep( 4000 ); //
4 seconds delay
/* load formula from external file */
AA.LoadFormula("Formulas\\Custom\\Optimization example\\optimization single
stock example.afl");
/* optional: load settings */
//
AA.LoadSettings("the_path_to_the_settings_file.abs");
/* set apply to and range */
AA.ApplyTo = 1; // use current
stock
AA.RangeMode = 0; // use all available quotes
//AA.RangeN =
1;
/* run explore and display report */
AA.Optimize(); //I cannot remember
whether you put a 2
AA.Export("C:\\"+Stk.Ticker + ".csv"); //you'd
ideally change this name to the ticker name
Doc.Close();
}
}
else
{
if(
Stk.WatchListBits2 & ( 1 << ( iWatchList - 1 )) )
{
Doc = AB.Documents.Open( Stk.Ticker );
/* load formula from external file */
AA.LoadFormula("Formulas\\Custom\\Optimization example\\optimization single
stock example.afl");
/* optional: load settings */
//
AA.LoadSettings("the_path_to_the_settings_file.abs");
/* set apply to and range */
AA.ApplyTo = 1; // use current
stock
AA.RangeMode = 0; // use all available quotes
//AA.RangeN =
1;
/* run explore and display report */
AA.Optimize(); //I cannot remember
whether you put a 2
AA.Export("C:\\"+Stk.Ticker + ".csv"); //you'd
ideally change this name to the ticker name
Doc.Close();
}
}
}
2) call this file c:\program
files\amibroker\Formulas\Custom\Optimization example\optimization single stock
example.afl
per1=Optimize("per1",50,20,100,10);
per2=Optimize("per2",50,20,100,10);
Buy = Cover= Cross(MA(C,per1),MA(C,per2));
Sell
= Short = Cross(MA(C,per2),MA(C,per1));
----- Original Message -----
Sent: Thursday, July 10, 2008 1:38
PM
Subject: RE: [amibroker] Optimization of
basket of stocks at individual stock level - possible with Ami ?
contact me off line.
d
d, I've been on this wild goose chase, as I had
said in the email below. Would you care to shed some light on how to
script this?
----- Original Message -----
Sent: Thursday, July 10, 2008 1:18
PM
Subject: RE: [amibroker] Optimization
of basket of stocks at individual stock level - possible with Ami ?
I've already got a script to do the job. Just wanted
to make sure you weren't sending someone off on a wild goose
chase.
d
dingo, I don't think it'll produce a neat
output as I had written it, no. I haven't done this type of thing
in a while, but when I did I recall running each test separately for
each ticker and then scrolling to the right to read the
report.
Creating a .js script that would call each
ticker separately and then save the results to a .csv file is one
possible solution. I cannot figure out how to get Amibroker to
scroll through the list of stock tickers in a watchlist using the Stock
object and then how to rename the report.csv to ticker.csv below.
Besides that, this should work. (One note, a wild way to do this
would be to have a separate ..tls file for each stock and then have
amiquote retrieve each .tls file in a directory using Example 2 in http://www.amibroker..com/guide/objects.html ).
If someone wants to chime in here and help with these outstanding
issues, that'd be nice.
/********************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;
/* here is where you'd call the ticker
name*/
/* load formula from external file */
AA.LoadFormula("Formulas\\Custom\\yourfilename.afl");
/* optional: load settings */
//
AA.LoadSettings("the_path_to_the_settings_file.abs");
/* set apply to and range */
AA.ApplyTo
= 2; // use current stock
AA.RangeMode = 1; // use all available
quotes
AA.RangeN = 1;
/* run explore and display report */
AA.Optimize(); //I cannot remember whether you put a 2 or
something else in here; recent beta docs say something about this, i
think
AA.Export("C:\\report.csv"); //you'd ideally
change this name to the ticker name
/********************Amibroker Save
Database***********************/
AB.SaveDatabase();
/********************Amibroker
Save Database (end)***********************/
AB.Quit();
----- Original Message -----
Sent: Thursday, July 10, 2008
12:23 PM
Subject: RE: [amibroker]
Optimization of basket of stocks at individual stock level - possible
with Ami ?
Are you sure that the individually
optimized params will appear on the resultant
report?
d
Elizabeth, the short answer is
yes. It requires that you call out parameters that are
specific to the ticker for each iteration the array processor goes
through.
So, you'd do something like this for
each ticker:
if
(Name()=="AAPL")
{
period=
Optimize("period",53,5,100,8);
}
----- Original Message
-----
Sent: Wednesday, July 09,
2008 11:45 PM
Subject: [amibroker]
Optimization of basket of stocks at individual stock level -
possible with Ami ?
Hello All,
I would greatly appreciate if someone can
tell me wheather it is
possible to optimize a basket of stocks
at individual stock level using
Amibroker. ie. to get separate
optimal parameters for each stock in the
basket.
Thanks
in advance
Elizabeth
__._,_.___
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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
__,_._,___