What if I want to automatically open charts/layout AND some Analysis windows in Amibroker? I can save charts in Layouts, but not Analysis windows. Those are saved in .apx files. And only one Analysis window is saved in an .apx file.
There is a way to open all desired windows, through OLE:
1) Create a JScript file (txt file with extention .js). In my case I named it AmibrokerPA.js. Inside it write code similar to this:
// I need to open Amibroker first, then execute this script
ab = new ActiveXObject("Broker.Application");
// close any open charts in Amibroker.
docs = ab.Documents() ;
docs.close() ;
// close any open AA in Amibroker.
adocs = ab.AnalysisDocs() ;
adocs.close();
ab.loadLayout ( "C:\\Program Files\\AmiBroker\\forex-hist\\Layouts\\PALiveAnalysis.awl");
ab.AnalysisDocs.Open( "C:\\Program Files\\AmiBroker\\Formulas\\Include\\PALower.apx" );
ab.AnalysisDocs.Open( "C:\\Program Files\\AmiBroker\\Formulas\\Include\\PATrading.apx" );
ab.AnalysisDocs.Open( "C:\\Program Files\\AmiBroker\\Formulas\\Include\\PAHigher.apx" );
ab.AnalysisDocs.Open( "C:\\Program Files\\AmiBroker\\Formulas\\Include\\PAExtraLarge.apx" ); 2) Teach Windows to run .js scripts with the C:\Windows\System32\wscript.exe :
From windows explorer, right click (on the .js file) > Openwith > Choose Default program, go to C:\Windows\System32 and select wscript.exe.
3) Open Amibroker.
4) From Windows Explorer, double click the AmibrokerPA.js script, to run it.
Note: This solution may be particular to my setup: Windows 7 64 bit with Amibroker 64 bit.
Resources:
https://groups.yahoo.com/neo/groups/amibroker/conversations/topics/189797http://www.amibroker.com/kb/2015/01/12/ole-automation-scripts-with-32-and-64-bit/