Good Morning
I want to be able to see on the charts the ticker along with the name of the
issue. In order to achieve this I have tried using a jscript program coming
from the book Introduction to Amibroker in Appendix C (Industries.js) that
should read the txt file that I created with all the tickers along with Full
Name of the issues from Russell 1000 index and establish the database. I keep
getting a script error. I am not a programmer and I am having a real challenge
to make this work. Can anybody help? I've tried to contact AB on this with no
success and samething with the author of the book.
Here is the script:
/*
** Amibroker/Win32 scripting Example
**
** File: Industries.js
** Created: Tomasz Janeczko, November 26th, 2000
** Last updated: Tomasz Janeczko, December 17th, 2000
** Purpose: Import Industy assignments
** Language: Javascript (Windows Scripting Host)
**
** The data is stored in lines with following format
** <ticker>,<full name>,<industry number>
**
*/
WScript.Echo( "Script Started" );
/* change this line according to your date file name */
ImportStocks("r1000fullname.txt");
WScript.Echo( "Finished" );
function ImportStocks( filename )
{
var fso, f, r;
var ForReading = 1;
var Amibroker;
var fields;
var stock;
/* Create Amibroker app object */
Amibroker = new ActiveXObject( "Broker.Application" );
/* ... and file system object */
fso = new ActiveXObject( "Scripting.FileSystemObject" );
/* open ASCII file */
f = fso.OpenTextFile( filename, ForReading);
i = 1;
/* read the file line by line */
while ( !f.AtEndOfStream )
{
r = f.ReadLine();
/* split the lines using comma as a separator */
fields = r.split(",");
try
{
/* add a ticker - this is safe operation,
in case that ticker already exists,
Amibroker returns existing one */
stock = Amibroker.Stocks.Add( fields[ 0 ] );
stock.FullName = fields[ 1 ];
stock.IndustryID = parseInt( fields[ 2 ] );
}
catch( e )
{
Wscript.echo( "There is a problem in line no."
+ i + ".\nThe line looks as follows:\n'" + r
+ "'\nIt will be skipped and next lines will be
processed as normal" );
}
i++;
}
/* refresh ticker list and windows */
Amibroker.RefreshAll();
}
Thank you
Max