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

[amibroker] Looping through DateRangeFrom and DateRangeTo with JavaScript



PureBytes Links

Trading Reference Links

Does anyone know the syntax(or entire code) for writing a javascript for
looping through RangeTo and RangeFrom Dates?

I modified the venerable batch script for backtests so it would do
optimizations instead.  However, rather than loop through all the files
in the folder using the same RangeFromDate and RangeToDate, I really
like to loop through different RangeDates with only one file/formula.

I realize this is almost the same as WalkForward Testing, except that I
need the resulting optimization report for each different batched
optimization.

Or, I could write the RangeFrom/ToDate into the AFL, but there doesn't
seem to be any way to do this.

I'm also considering using EnableScript and writing a short script at
the beginning of each AFL with a different date each file and then batch
testing the whole lot.  Best would be a loop.

I can't find anything on the syntax for looping through RangeTo and
RangeFrom Dates.

Balin

//Batch Optimizer
BatchOptimizeFolder="C:\\Program Files\\Amibroker\\BatchOpt";
WScript.Echo("Batch Optimization  ");

var AB,AA;
var fileSysObj, folder, folderCount, f1,s;
var fileName,reportName;
fromDate=new Date(2000,00,01);
toDate=new Date(2006,00,01);
AB=new ActiveXObject("Broker.Application");
AA=AB.Analysis;
AA.ClearFilters();
AA.RangeMode=3;     // 3: from-to date  // 2: n last days
//AA.RangeN=600;
AA.RangeFromDate= fromDate.getVarDate();
AA.RangeToDate= toDate.getVarDate();
AA.ApplyTo=2;      // 2: Use filters
AA.Filter(0,"WatchList") = 13;  // 0: include   13: Nasdaq 100
//AA.LoadSettings("C:\\.....\\SettingFilexxx");

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-3) + ".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/