Open apx file from an already open analysis window

I tried this using a few ways but i'm unable to, the only way is to

File > Open > browse to apx file > select

but this opens a new analysis window.
These new windows then affects the layout each time.

Only files i'm able to load/open are either the .ABS or .AFL files, but not APX.

Thanks.

Win10 64b, AB 6.28 32b Pro

Analysis project file opening in currently open analysis window or separate one depends on the name of the analysis tab and the project file name. So if you already have opened a project file such as "Analysis1.apx" then the analysis tab name becomes "Analysis1.apx" too. If you try to re-open project with same name then it will open in same tab again. If you open another project file such as "Analysis2.apx" then it will open in separate analysis window (since it has different name).

That is not the only way. Another way of opening recently opened Analysis projects quickly is going to File - Recent Files. Via Tools - Customize - Commands - File you can drag and drop "Recent Files" to menu bar of AB to have quicker access to that menu (also you can rename "Recent files" to something else such as "MRU files" or ... whatever).

707

If you just want to open a different AFL in same analysis window then just open a different AFL instead of project file. Also recently used AFLs can be moved from "File - Recent Formulas" to menu bar (see picture above again - just renamed "Recent formulas" to "MRU AFLs" after having moved it to there).

3 Likes

Thanks for the elaborate inputs.

I considered "Recent Files" as one of the ways in the "using a few ways" :slight_smile:

My actual need started out from saving Layouts.
currently, the Layout saves only chart windows, I don't think Analysis are saved.

Analysis can of course be of two types, named (something.apx) or unnamed (AnalysisX)
I tried saving them using Layouts, but the charts retain the latest layouts and window size but blank slots where the Analysis windows were.

Greater trouble I have is in the order of those windows, because I use OLE to run the exploration and the export command sends output to .CSV files but unable to enumerate the order of the windows.

NewA = oAB.AnalysisDocs.Item(0); // I have 3-4

If I use the Load file option
NewA = AB.AnalysisDocs.Open( "C:\\analysis1.apx" );
then windows are created and closed, if you run it every few minutes, then unable to work with the UI.

so far, I open each Analysis window in a specific order, and then let my script run.
I know I can automate the whole thing from AFL including exporting results to file so i'll have to rewrite my stuff during a vacation :slight_smile:

then just run all from here

NewC = oAB.AnalysisDocs.Count;		// get total analysis windows
        for (i = 0; i < NewC; i++) {
        NewA = oAB.AnalysisDocs.Item(0);       // 1st analysis starts with 0
        /// my other 
1 Like

@travick,
No, analysis windows are not (yet) part of Layout.

If you want to run currently opened Analysis windows in some interval (via task scheduler) then you might do as follows...

Below code executes all already opened analysis windows with own analysis mode (and keeps them open)...
So in example below Analysis tab 1 runs Exploration, tab 2 runs Scan and tab 3 runs Backtest. All remaining open analysis windows run exploration (well, I have added 'if' statement to only run first N open analysis windows. So if you want to execute more than three ones then change 'if' statement accordingly).

/// This is Jscript not AFL!
/// https://forum.amibroker.com/t/open-apx-file-from-an-already-open-analysis-window/7571/4
/// https://groups.yahoo.com/neo/groups/amibroker/conversations/messages/190035
/// run OPENED Analysis window(s) with individual run modes
AB = new ActiveXObject("Broker.Application");
AD = AB.AnalysisDocs();
Adoc = new Array();
Aqty = AD.Count();

scan = 0;
exploration = 1;
portfolio_backtest = 2;
individual_backtest = 3;
optimization = 4;
individual_optimization = 5;
walk_forward = 6;

for ( i = 0; i < Aqty; i++ ) {
	Adoc[i] = AD.Item(i);
}

for ( i = 0; i < Aqty; i++ ) {
	switch( i ) {
		case 0:		runmode = exploration;			break;// Analysis 1 run mode
		case 1:		runmode = scan;					break;// Analysis 2 run mode
		case 2:		runmode = portfolio_backtest;	break;// Analysis 3 run mode
		default:	runmode = exploration;			break;// all others
	}
	//	
	if( i <= 2 ) // only run first three analysis windows   
		Adoc[i].Run(runmode);	
	//
	//WScript.Sleep( 100 );
}

Or well, if all analysis are supposed to run at same analysis mode (e.g. exploration) then just comment (or remove) switch statement and just add Adoc[i].Run(..) with some run mode:

/// This is Jscript not AFL!
/// https://forum.amibroker.com/t/open-apx-file-from-an-already-open-analysis-window/7571/4
/// https://groups.yahoo.com/neo/groups/amibroker/conversations/messages/190035
/// run OPENED Analysis window(s) with individual run modes
AB = new ActiveXObject("Broker.Application");
AD = AB.AnalysisDocs();
Adoc = new Array();
Aqty = AD.Count();

scan = 0;
exploration = 1;
portfolio_backtest = 2;
individual_backtest = 3;
optimization = 4;
individual_optimization = 5;
walk_forward = 6;

for ( i = 0; i < Aqty; i++ ) {
	Adoc[i] = AD.Item(i);
}

for ( i = 0; i < Aqty; i++ ) {
	// switch( i ) {
		// case 0:		runmode = exploration;			break;// Analysis 1 run mode
		// case 1:		runmode = scan;					break;// Analysis 2 run mode
		// case 2:		runmode = portfolio_backtest;	break;// Analysis 3 run mode
		// default:	runmode = exploration;			break;// all others
	// }
	//	
	if( i <= 2 ) // only run first three analysis windows   
		Adoc[i].Run(exploration);	// instead of Adoc[i].Run(runmode);	
	//
	//WScript.Sleep( 100 );
}
6 Likes

Thanks for writing all the code.
My code is very similar :smiley:

Only thing if you notice is that the order of AnalysisDocs.Item(x) depends on the order of Analysis windows opened.

So if for some reason, the order changes, then OLE javascript has a problem figuring out which is which.
since I wrote earlier, AnalysisDocs.Export() fn is what I use, the resultant file will also get jumbled up.

Lets look forward to TJ adding these suggestions to future versions.

This is a separate issue but i'm looking for a future Preference setting to disable import Logging as a choice, many tools that aren't developed as data plugins use OLE Import and by Eod import.log is around 5MB in size.
that's one write per second,