Do I need to create a new ActiveXObject to Run a .apx file with OLE?

In the manual we run;

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

    NewA = AB.AnalysisDocs.Open( "C:\\analysis1.apx" ); // opens previously saved analysis project file
    // NewA represents the instance of New Analysis document/window

    if ( NewA )
         NewA.Run( 2 ); // start backtest asynchronously

         while ( NewA.IsBusy ) WScript.Sleep( 500 ); // check IsBusy every 0.5 second

         NewA.Export( "test.html" ); // export result list to HTML file

         WScript.echo( "Completed" );

         NewA.Close(); // close new Analysis
catch ( err )
     WScript.echo( "Exception: " + err.message ); // display error that may occur

I note however that we can run a batch by

broker.exe /database "C:\program files\amibroker\mydatabase" /runbatch "C:\" /exit

The batch will probably work fine for most of the things I am looking to do, but I iwll at some point want to be automating capturing image files taken at certain moments when things happen, and store them, and I'm anticipating I may not be able to do that

Is there an equivalent of /runbatch, e.g /runproject, or would we need to write a full script as above? Also, if there is an equivalent if I was looking to run a backtest (e.g portfolio backtest is option 2) as opposed to an exploration (option 1), where would I specify that option? would I write something like;

broker.exe /database "C:\program files\amibroker\mydatabase" /runproject /2 "C:\yourproject.apx" /exit

Much obliged.

Many thanks.

You should use batch if you want command line control. Batch gives more possibilities, including running multiple analyses in one go and running different actions.

1 Like