Hi.

Using OLE/jscript, I would like to do the following:

1.    Start AB
2.    Choose a database

In a loop across multiple symbols (symbol names known in advance):

3a.        Open a chart and apply an AFL

     or

3b.        Open a saved layout that has a given AFL applied

4.    Quit AB


I've done a good amount of both Googling and experimenting, but I 
haven't hit on the right sequence yet to accomplish this.

It is only step 3 that I'm having a problem with.   My problem is not 
executing the loop.  That seems fine.

However, nothing I have found or tried opens/loads a chart and 
applies/runs an AFL.

Below is skeleton code that runs.

If someone is able to be so kind as to fill in the missing bit, I'd 
really appreciate it.   If there's more than one way to do it, 
alternative solutions are very welcome.

Thanks.

---


/*
     LoopDemo_01.js

     _01        201007089    Initial "empty" skeleton by Progster

     It is recommended to run this file in a command window, like so:

 >cscript LoopDemo_01.js

     Lines commented with //    *** will need to be edited to reflect 
the local environment

     Goals:

         1.    Start AB
         2.    Choose a database

         In a loop across multiple symbols (symbol names known in advance):

         3a.        Open a chart and apply an AFL
             or
         3b.        Open a saved layout that has a given AFL applied

         4.    Quit AB


*/

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}

//    General paths and setup definitions
Settings_Directory = "C:\\Amibroker_Formula_Root\\";                // ***
SettingsFileName = "Futures_01.ABS";                                // ***

Layout_Directory = "C:\\AmiBroker_Data\\US-PremiumData\\Layouts\\"    
//    ***
LayoutFileName = "MyLayout.ALY";    //    ***

SettingsFile = Settings_Directory + SettingsFileName;
WScript.Echo( "SettingsFile: "  + SettingsFile );

LayoutFile = Layout_Directory + LayoutFileName;
WScript.Echo( "LayoutFile: "  + LayoutFile );

AFL_Directory = "C:\\Amibroker_Formula_Root\\Custom\\";    // ***

// Create AmiBroker object
AB = new ActiveXObject("Broker.Application");

// Load Database
AB.LoadDatabase("C:\\Amibroker_Data\\US-PremiumData");    //    ***

//    Test of changing symbols        //    ***
var symbols = new Array(4);
symbols[0] = "$SPX" ;
symbols[1] = "GOOG" ;
symbols[2] = "AAPL" ;
symbols[3] = "SPY" ;
//    symbols[] = "" ;

for (idx = 0; idx <= 3; idx++)
{
     next_symbol = symbols[idx];
     WScript.Echo( "Working on: " + next_symbol);

     //    Aim is to load a chart here, and load code (which will run 
and generate the desired result)

     ChartFileName = "My_Chart_File.afl";            // ***
     ChartFile = AFL_Directory + ChartFileName;
     WScript.Echo(ChartFile);

     pausecomp( 1000 ) ;
}

AB.SaveDatabase();
AB.RefreshAll();

pausecomp( 1000 ) ;

WScript.Echo("Closing AmiBroker");
AB.Quit();

WScript.Echo("Pipeline is Done.");

Reply via email to