I'm trying to develop a workflow and shortcut commands for saving and opening last session that includes chart and analysis windows.
// I need to open Amibroker first, then execute this script
ab = new ActiveXObject("Broker.Application");
// close any open charts in Amibroker.
docs = ab.Documents() ;
// close any open AA in Amibroker.
adocs = ab.AnalysisDocs() ;
ab.loadLayout ( "C:\\Program Files\\AmiBroker\\IntradayUpdateDB\\Layouts\\Default.awl");
ab.AnalysisDocs.Open( "C:\\Program Files\\AmiBroker\\My Analysis\\SystemBuild\\ EMA System.apx" );
ab.AnalysisDocs.Open( "C:\\Program Files\\AmiBroker\\My Analysis\\DAILY SCAN\\BTST.apx" );
Appreciate comments and advice on this.
Also, it would be awesome if the experienced can share on how you guys track working sessions.
Is there a way to get the list of the opened analysis .apx files in Amibroker and assign this to a variable via JS? I have looked into the AB object model documentation but could not find any info about this.
Any advice is appreciated.
I see, you have already done some research and probably came across these threads in which very similar issues have been discussed:
Although I'm using jscripts and OLE, I'm definitely not an expert in this field - but I think it is not possible to retrieve (using OLE) names and paths to all open Analysis windows (not just number of all open AA windows). That would allow keeping track and updating this jscript file which opens all recently used AA windows after AB restart. If I'm wrong I would appreciate correcting me and showing an example code.
For this reason, currently I don't see a better option than opening apx files and rearranging them on the screen(s) manually (or using jscript + OLE just to open them) after each AB restart. Of course you can make a shortcut in the menu bar to the Recent Files. For me the biggest problem is not opening those apx files, but rearranging them manually on my monitors before each session. These repetitive tasks unnecessarily take time every single day.
As I wrote in another thread, I know, there could be also some disadvantages of saving AA Windows in the Layouts, but if that is the case, there is probably another way of achieving that - for example some additional/optional layouts only for AA Windows. Another awaited feature is implementing Analysis windows’ unique IDs - that would make possibe using separate Parameters for each AA window.
If you (or for example @travick) are interested in implementing these features, you can upvote Issue #2653 - Save AA Window in Layout in the Feedback Centre. It's current status is "put on hold" - so there is a chance it might be implemented in the future...
Thanks @Milosz for the thread reference, tried to find related topic but couldn't find the best keywords.
I have the feeling that it's not possible to retrieve names and path of all open analysis windows based on the OLE documentation.
Good idea on using Recent Files. Will have a look at it.
Thanks @travick for sharing your setup. I got your point, having the ability to track the order of analysis windows is crucial for a practical automated windows loading.
I guess, until there's a better way, for the time being I'll just stick to the manual way of updating my JS script to store the important analysis.apx file for loading in the next session.
There are many ways of opening apx files from AmiBroker. A few examples:
File --> Open --> *.apx
Creating a shortcut to the Recent Files or/and Recent Formulas in the main menu bar. An example here:
Creating shortcuts (also in a form of small icons) in the main menu bar to Custom tool items (https://www.amibroker.com/guide/w_customize.html). They allow to easily run external programs or scripts. Starting from AB 6.29 you can have up to 20 custom tool items.
Using Gui Buttons. Each button can run one or more external scripts via ShellExecute(). You can even create a kind of a custom "control panel" in a separate chart, with a set Gui buttons and some additional controls.