PureBytes Links
Trading Reference Links
|
I'm having a problem with the following script. It runs fine, but
does not filter out all symbols except those in the "S&P 500" group
in my database. I am getting "All" symbols in the database.
Can anyone tell me where I'm going wrong???
Here's the code:
/* -***- c:\data\Scripts\OptimizationBatch.js -
***-
* * Mon Aug 09 00:19:06 2004 rpc -
* This is a JavaScript that batchs up Optimizations on a list of
stocks. (You provide the
optimization routine
* in the call to LoadFormula).
* The optimization will be run on each instrument in the watch list
and results saved to a csv
file.
*
* The following variables need to be set (you'll probably want to
set others as well):
* optimizationRoutine - your optimization routine.
* exportDirectory - directory to save the exported-from-Amibroker
optimization reports.
*/
/* First: many thanks to the original author!!
I've modified this scipt to run optimizations for each ticker in a
group.
As a starting point, this script simply writes each ticker symbol
to an ascii file.
*/
var i;
var s;
WScript.Echo( "Script Started" );
// init the variables
optimizationRoutine = "c:\\data\\AmiBroker\\systems\\xxx.afl";
exportDirectory = "c:\\data\\AmiBroker\\Systems\\xxx study\\";
// create an instance of the object
AB = new ActiveXObject("Broker.Application");
WScript.Echo( "Current path to database is " + AB.DatabasePath );
AA = AB.Analysis;
// load the formula that we want to run
AA.LoadFormula(optimizationRoutine);
// filter the data
AA.ClearFilters(); // clear existing filters
AA.ApplyTo = 2; // tell AA to use filters
AA.Filter( 0, "group" ) = 3; // group = S&P 500 = 3 in my
database
// set date range for optimizations
AA.RangeMode = 3; // from-to Date
AA.RangeFromDate = "1/1/2003" // from date
AA.RangeToDate = "12/31/2003" // to date
// get the array of tickers
stocksArray = AB.Stocks.GetTickerList(0).split(",");
// for testing, we need a text file
fso = new ActiveXObject( "Scripting.FileSystemObject" );
f = fso.OpenTextFile("c:\\data\\AmiBroker\\Systems\\xxxSar
Study\\test1.txt",2, true);
f.WriteLine("begin" + AB.Stocks.Count);
// run the optimization for each ticker in the stocksArray
for(i = 0; i < AB.Stocks.Count; i++) {
// to prove that I'm getting the correct tickers,
// write i and ticker to the text file
s = i.toString();
s = s + " " ;
s = s + AB.Stocks.Item(stocksArray[i]).Ticker;
f.WriteLine( s);
}// for
// clean up
f.WriteLine("end");
f.Close();
WScript.Echo( "Script Completed" );
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|