Convert script (read symbols and activate) to AFL


I am not a programmer have some programming background. I have stiched around a the following cscript by googling and through this forum. I read that it is not adviceable to use com script, so want to convert this script to afl please let me know
Thanks and Regards

//iWatchList = 66;
AB = new ActiveXObject("Broker.Application");
//AB.loadLayout ( "C:\Program Files (x86)\AmiBroker\Layouts\Activate.awl");
//docs = AB.Documents();
//doc = docs( 0 );
AW = AB.ActiveWindow;
stks = AB.Stocks;
Qty = AB.Stocks.Count;

for ( i = 0; i < Qty; i++ )
Stk = AB.Stocks( i );

AD = AW.ActiveDocument

// AD = AB.ActiveDocument;
AB.ActiveDocument.Name = Stk.Ticker;
WScript.Sleep( 10 )
AB.ActiveDocument.Name = Stk.Ticker;
WScript.Sleep( 10 )
AB.ActiveDocument.Name = Stk.Ticker;
WScript.Sleep( 10 )
AB.ActiveDocument.Name = Stk.Ticker;
WScript.Sleep( 20 )

// WScript.Sleep( 2000 );


@mahmed4 this script is a modified version of what was posted in the AmiBroker KB here:

How to browse charts in selected date range

It is always better to refer to the original!

Anyway, it is perfectly fine to use OLE for this kind of things (mainly creating a slideshow of all tickers in a specific watchlist).

On the other hand, if you want a slideshow using AFL you could start looking at this code originally posted by Herman van den Bergen in the old Yahoo group and try to modify it as per your needs:

(see also the other messages in that Yahoo thread to get ideas how to use it in a multi-panes chart properly)

There was also a revised version by "progster" cited in this other thread, but the link to the code now seems unreachable.

P.S. When you post some code in this forum you are supposed to use the </> code button to display it properly formatted.

How to paste code samples

Thanks for the reply. This was my first posting and dint know how to paste the script. Will do it in future. I see there is a clear help window in the right side i dint observer.

But the issue with OLE is when i close AB there is background process keep running which doesnt gets killed/closed. Due to this when i reopen AB, my feed provider thinks its a second login and doesnt allow me to connect.

Background task of AB is still active and consume memory and cpu

@mahmed4 I tested the script on my machine, and it works well (no Broker.exe is left when the slideshow is completed, and the script is automatically terminated).

I also tried to close manually AmiBroker while running the slideshow: I got a jscript error dialog but closing it also terminated the Broker.exe process.
So I cannot further help on this issue. Sorry.

In any case, take some time to explore the AFL code I suggested!

@mahmed4 - you are most likely running 3rd party plugin or 3rd party add-on that prevents exit.

Remove 3rd party add-ons and 3rd party plugins or ask 3rd party vendor to fix their addon/plugin.

Yes am using 3rd party plugin for intraday/eod data.
Please provide me a pointer so that i can take this up with vendor. Appreciate your help