Sync Analyisis Window with CUSTOM chart

I have multiple Analysis windows and multiple Chart Templates with multple Chart Spreadsheets. I know the capability of explorer result´s list to "sync on chart" with the last open chart. I also use the "Symbol Link" tool to expand this connection.
My question is this: IS IT POSSIBLE TO TELL AMIBROKER TO OPEN A SPECIFIC CHART SPREADSHEET WHEN SELECTING SYMBOLS FROM A SPECIFIC ANALYIS WINDOW?

It would be synchronizing with the desired spreadsheet in a chart template, which is not necesarily the last opened chart. I think it is not possible, but I want confirmation from the experts.

Thanks in advance,
Mariano

hi, I have searched the forum and the knowldege base, I have tried myself and I think it is not possible, but I need confirmation from the experts in Amibroker. I restate the question:

Is it possible to tell Amibroker to open a specific chart when clicking a specific analyisis window expolorer result list? At the moment, opens the last opened chart.

hope i explained myself,
thanks in advance
Mariano

It opens last ACTIVE chart window. You can change ActiveDocument via OLE http://www.amibroker.com/guide/objects.html
So in theory you could place in your code OLE calls that change active chart window when Analysis is run to something of your choice.

1 Like

Thanks Thomasz.
Since I am analphabet in .js, I would like to ask you a question to start working in it or not.
The question is if it would be possible to write a .js that tells Amibroker to:
1.check which Analysis Window is opened and ACTIVE,
2. move to the activate the next sequential Analyisis window (assuming there are several analysis windows which are not floating)
3. Activate a specific chart which is in the layout but it is not active.

Thanks in advance,
Best regards
Mariano

Composing a Batch would be simpler! Instead of checking which Analysis Window is Open, using Batch you can easily control the sequence of which .APX to run and store its result accordingly.

Please read this guide Using Batch window.

You can do that using OLE from native AFL itself - no need for JS. Anyways, using StaticVars you can always control the number of its executions.

Then make it a part of the same Batch.

The idea of Batch is not what I need. I use a .js for running several explorations, and I use the code that I found in the Tomasz documentation as an example:

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

try
{ 
	NewA = AB.AnalysisDocs.Open( "C:\\Program Files\\Amibroker\\Formulas\\Custom\\batch\\1F-Sec.C.1.apx" ); 

    if ( NewA )
    {
         NewA.Run( 1 ); // start exploration asynchronously
         while ( NewA.IsBusy ) WScript.Sleep( 2000 ); 
     }

..... This code for several .apx.

So what I have is several Analysis alrady runned. I am not interested in neither opening or running again the Analysis projects. I just want to know how to associate an already opened and runned analysis project with a specific chart that is not opened at this moment.

I have been trying to study the documentation that Tomasz signaled about OLE , and I think that it may be related with

AnalysisDocs and ITEM

, but I have no capacity to program it.

I have tried with things like

oAB = new ActiveXObject("Broker.Application");

NewC = oAB.AnalysisDocs.Count;	// get total analysis windows

NewA = oAB.AnalysisDocs.Item(0);	// 1st analysis starts with 0

Finally, for the chart that I want to activate, I guess that it would be something similar to this

docs = ab.Documents(1167) ;
doc = docs(0);
docs.Activate();

being 1167 the chart ID I want to activate....

Sorry for the incompetence, but in terms of OLE automation, beyond the example that is given in the documentation to run sequential explorations, I have no way of writing anything properly.

Well in your previous post you mentioned on how to:

There was no Chart Id then. So while you scroll through your ideas, expanding the same thought on how to achieve same goals natively using AFL. Might help!

Let's say we have 2 Global Layouts, namely, JustPrice and Price-n-Volume:

image

And these Layout files are saved in the default Layouts folder, i.e. /AmiBroker/Layouts. In my case it is:

image

A simple OLE example in order to change the layout:

//Programatically Change Layout using OLE from native AFL
_SECTION_BEGIN( "OLE Change Layout" );
	 ChLayout = ParamToggle( "Choose Layout", "Price|Price and Volume", 1 );
	 //Using ParamTrigger here to Execute. There are many other ways - circumstantial!
	 ChTrig = ParamTrigger( "Change Layout", "Go" );
	 
	 if( ChTrig ) {
		 switch( ChLayout ) {
			 case 0:
				 FilePath = "C:\\Trading Apps\\AmiBroker\\Layouts\\JustPrice.awl";
			 break;
			 case 1:
				 FilePath = "C:\\Trading Apps\\AmiBroker\\Layouts\\Price-n-Volume.awl";
			 break;
		 }	 
		 
		 App = CreateObject( "Broker.Application" );
		 //Change the FilePath as per your AmiBroker installed directory
		 App.LoadLayout( FilePath );
	 }
_SECTION_END();

Click on the image for expanded view:

The OLE examples are in JS, in order to demonstrate how AmiBroker can be controlled externally. But in this case, you can easily use OLE from AFL itself.

Carefully study this image (it says it all) as you experiment different options from the OLE guide.

image
(Image Source: OLE Automation Object Model)

3 Likes

What a shame on me! You are absolutely right, Cougar. I was trying to get to what I need by a extravagant OLE automation, when I just need to change the Layout to activate the chart that I want. Now I understand why Analyisis windows do not belong to layouts. I think I do not even need the code you kindly wrote for it. Sorry for taking your time, I just want to remind everyone that Amibroker is universal... even for the programming illiterate... Cheers and Thanks

1 Like