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

Re: [amibroker] How do I read dir names in AFL



PureBytes Links

Trading Reference Links

Dennis - 

Not in AFL but in jScript that you can put in your AFL scripts.   There's a function in jScript(C++ as well?) called Enumerator that you can use to get the list of files in a directory as shown below.  This is in a routine for automated back test that's somewhere in the Amibroker library from 2002.  

I also have it written as a more generalized function and if you'd like further help write to me directly.

Hope this helps,   

Joe Landry

f = fso.GetFolder(AFLFolder);

fc = new Enumerator(f.files);

for (; !fc.atEnd(); fc.moveNext())

/*****************************

*

* 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: Dec 22, 2002 TJ

*

* 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:\\Program Files\\AmiBroker\\AFL"; // MODIFY TO FIT YOUR SETUP

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.Backtest();

         

          reportname = filename.substr( 0, filename.length - 3 ) + "HTML" ;

         

          AA.Report( reportname ); // generate report

       }

    }

}

----- Original Message -----
Sent: Monday, January 14, 2008 10:33 PM
Subject: [amibroker] How do I read dir names in AFL

Hello,

I am stumped on this problem. I want to read the names of a set of
folders that are inside another folder. I want to do this in AFL
because, I want to make a pulldown list param of the folder names. I
will use this to select a parameter set to switch to. Right now, I
have to remember the names of the folders or look them up in Explorer
and type the name into a text field param. I would rather be able to
just select from a list of the valid folders that were created.

I could do this indirectly if I keep track of every folder I ever
created in a file, and then use that list. However, it would require
a lot of housekeeping code to clean up this list from manual
additions and deletions in Explorer.

Does anyone know how to read the folder names directly?

Thank you,
Dennis

__._,_.___

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___