[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Script question



PureBytes Links

Trading Reference Links

I have been looking into the possibility to run optimisation using 
the "Backtest.js" script published here by TJ some time ago. I 
changed some of the script (minor changes) as you can see below, and 
it does the job. Except when optimisation is too large :-(( 

The script runs up to AA.Optimize(); where Amibroker says "The 
formula requires eg. 20,000 optimisation steps. This may take lots of 
time. Are you sure to proceed Yes/No?" Would it be possible to bypass 
this somehow, add a line of code into the script, etc. 

Thanks, 

Greg




/*****************************
*
* BatchTest.js
*
* Batch testing sample script
* Shows how to use JScript and new AmiBroker 4.23
* 'Analysis' object to perform batch backtesting
* and generate reports
*
* Created: Dec 21, 2002 TJ
* Last modification: Feb 17, 2003 by "me"
* 
* Copyright (C)2002 Amibroker.com
*
* Status: Freeware
* You can use/modify/adopt this code freely
*
*/

/* The directory where AFL files are stored
** Also reports generated by the bactest
** will be saved here
*/


AFLFolder = "C:\\Test";

WScript.Echo("Batch testing of all AFL files stored in " + 
AFLFolder );

var AB, AA;
var fso, f, f1, fc, s;
var filename;

/* Create AmiBroker object and get Analysis object */

AB = new ActiveXObject("Broker.Application");
AA = AB.Analysis;

/* backtest over symbols and all quotes*/
AA.ClearFilters(); 
AA.ApplyTo = 0; // use symbols
AA.RangeMode = 0; // all quotes

/* to use filters you should uncomment lines below

// AA.ApplyTo = 2; // use filters
// AA.Filter(0,"watchlist") = 2 /* watch list number */;
// AA.Filter(0,"group") = 0 /* group number */;


/* Create FileSystemObject */
fso = new ActiveXObject("Scripting.FileSystemObject");

/* Iterate through all files in the folder */
f = fso.GetFolder(AFLFolder);
fc = new Enumerator(f.files);
for (; !fc.atEnd(); fc.moveNext())
{
    // we need to add empty string to make sure that filename is a 
string object
    filename = "" + fc.item();	

	/* check the AFL extension */
	if( filename.substr( filename.length - 4 ).toUpperCase() 
== ".AFL" )
	{   
		if( AA.LoadFormula( filename ) )
		{
			AA.Optimize();
                        
			reportname = filename.substr( 0, 
filename.length - 3 ) + "CSV" ; 
	
			AA.Export( reportname ); // generate report
		}
	}
}

WScript.Echo("Batch backtest finished");


Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/