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

[amibroker] Re: Looping through DateRangeFrom and DateRangeTo with JavaScript



PureBytes Links

Trading Reference Links

OK, this works.  Batch optimizer with cycling date range and multiple
files.  Outputs full optimization reports for each test with formula
name and date range in title.

Balin

/*Batch Optimizer
Batch Optimizes multiple formulae, cycling each formula through multiple
date ranges
Outputs optimization report for each test with formula name and date
range in title

Before each batch, manually code your desired Filter (ieWatchlist, etc),
the date you
want the tests to begin ("year", in the for init), when you want them to
end (year in middle
of for definition, and the length of each range ("rangeLength").
Put all the formulae you wish to test in one folder and enter the folder
name in the first line
of the script.  Run the .js and come back when it is all done.  Take up
golf.
*/
BatchOptimizeFolder="C:\\Program Files\\Amibroker\\BatchOpt";
WScript.Echo("Batch Optimizer Variable Date Ranges.js ");

var AB,AA;
var year,rangeLength;
var fileName,reportName;
var fileSysObj, folder, folderCount;

AB=new ActiveXObject("Broker.Application");
AA=AB.Analysis;
AA.ClearFilters();
AA.RangeMode=3;     // 3: from-to date
AA.ApplyTo=2;      // 2: Use filters
AA.Filter(0,"WatchList") = 13;  // 0: include watchlist #:
//AA.LoadSettings("C:\\.....\\SettingFilexxx");
rangeLength=2;

for ( year=2000;   year<2005;   year=year+rangeLength )
{
  fromDate=new Date(year,00,01);
  toDate=new Date(year+rangeLength,00,01);
  AA.RangeFromDate= fromDate.getVarDate();
  AA.RangeToDate= toDate.getVarDate();

  fileSysObj=new ActiveXObject ("Scripting.FileSystemObject");
  folder= fileSysObj.GetFolder(BatchOptimizeFolder);
  folderCount=new Enumerator (folder.files);

  for (     ;  !folderCount.atEnd();   folderCount.moveNext()  )
  {
    fileName=  ""  + folderCount.item();
    if (fileName.substr(fileName.length-4).toUpperCase() == ".AFL")
    {
      if (AA.LoadFormula (fileName))
      {
        AA.Optimize (0);   // 0: portfolio     1: individual     2:  old
        reportName=fileName.substring(0,fileName.length-4) + "-" +year
+"-" + (year+rangeLength)+".html";
        AA.Export (reportName);
      }
    }
  }
}
WScript.Echo ("Batch Optimization Completed");







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
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/