How to change the displayed ticker in active window with OLE or AFL

Hello to community,

I want to change the ticker in the active window. I try this JavaScript but I have error in line 2

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

AB.ActiveDocument.Name = " TSLA";

I know the existing of slide show afl code in the forum, that use SetForeign(Ticker);
But I need to do something else.
I want to change the ticker in the “type or select symbolfield of Amibroker interface.

Can someone help me with this? Thanks in advance for every good mood. !!



If you remove the leading space from " TSLA" this jscript might work. At least it works properly in my case. If not, you might find the source of your problem here:

By the way, you can also change the ticker directly from AFL (three lines of code), although you must be extra cautious in this case. For example:


Thanks a lot for pointing out the space inside the ticker. Also, reading the link you indicated I managed to solve the problem through cmd by writing the following command.
C:\Windows\SysWOW64\CScript.exe R:\CHANGE_TICKER_TEST.JS

Note_No1: CHANGE_TICKER_TEST.JS file has two lines

AB = new ActiveXObject("Broker.Application");
AB.ActiveDocument.Name = "TSLA";

(Note_No2: win10-64x, amibroker 32x).


1 Like

Following the thread I would like to go one step further. So far we have managed to activate a ticker in the running TAB. Can this be done in another TAB? Through a lot of effort and reading I thought that the next line (3rd line) will succeed, but no, it does not. I would like your help if what I ask is possible.

AB = new ActiveXObject("Broker.Application");
AB.ActiveDocument.Name = "TSLA";
AB.Item(1).ActiveDocument.Name = "TSLA"; // in this line I ask for your help.

@chrismet Have you checked the link that I gave you in my reply? I don't think so, because in that other thread you can find codes changing tickers in selected (not necessarily active) chart windows (chart windows, not chart tabs):


Anyway if you want to change ticker in the third chart window of your layout, here is how you can do it from jscript:

AB = new ActiveXObject("Broker.Application");
SelectedDoc = AB.Documents(3); 
SelectedDoc.Name = "TSLA";

and directly from AFL:

if( ParamTrigger( "Change Ticker", "Yes" ))

	AB = CreateObject( "Broker.Application" );
    doc = AB.Documents( 3 );
    doc.Name = "TSLA";

Important: read all the warnings about using OLE from AFL in that other thread.

I use a similar AFL code to change tickers in selected chart windows to automatically synchronize them with the newsflow coming (during the session) from different sources and it works well.


Dear @Milosz, I want to thank you from the bottom of my heart for spending your precious time helping me.
I could see your justified bitterness for not paying proper attention to your answer.
I clicked on the link and saw the code, but the lack of availability of the necessary experience on my part is the culprit.
My mind was stuck that I want something that has nothing to do with Foreign() and so as soon as I saw it I did not go to the next lines of code where there was the useful (really) registration that would help me, even for java through which I already had start trying to solve my problem.
Eventually it is what we say "you did not leave me alone", and you kindly came back to offer me three lines valuable to me to reach the end.
I have no words to thank once again. !!!
So the "one more step further" that I was asking for, was solved with your exclusive valuable help.


This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.