Javascript to handle active Window with loop

outputdrive = "d:\\temp\\";

saveimage = outputdrive;

var oAB = WScript.CreateObject("Broker.Application");


ADS = oAB.Documents;

ADS.Item(0).ActiveWindow.ExportImage( "D:\\TEMP\\BANKNIFTY.png", 1000, 560); // chart 1

ADS.Item(1).ActiveWindow.ExportImage( "D:\\TEMP\\NIFTY.png", 1000, 560); // chart 2

ADS.Item(2).ActiveWindow.ExportImage( "D:\\TEMP\\TATASTEEL.png", 1000, 560); //

If I want more chart then I need to add more lines to export chart.

And also I need to open chart on amibroker in same series.

Hence I want to add loop, So that all open charts will save as image by the name
of active Window name

Please help..

The above code is working fine in Javascript.

I want to run above codes for 35 script hence i want to use a loop.

In loop ADS.Item(no). and EXPORTIMAGE file name will be variable for 35 charts.

Anyone can tell me how to put above codes in a loop so that active charts will be saved in drive c:\temp

You should not create 35 charts for mere purpose of exporting chart from them.
Instead you should just use ONE chart window (active one) and change the symbol:

doc = oAB.ActiveDocument;
doc.Name = "NIFTY";
doc.ActiveWindow.ExportImage( ... );
doc.Name = "TATASTEEL";
doc.ActiveWindow.ExportImage( ... );
// and so on

Doing so consumes way less resources than opening 35 charts.

As far loops are considered there are plenty of examples how to loop over list of symbols. Use Google.

3 Likes

Dear @Tomasz
OPs Duplicate threads was previously locked where this has been discussed.

this guy is like a serial offender :frowning:

I am not good in javascript can u pls share full code.. It will be useful to everyone..

I I tried with loop but loop is not selecting next window.

Humble request please share codes here.

Thank you in advance.