[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WatchList Import Question - Solution Found !!!!!



PureBytes Links

Trading Reference Links

I found a way to skin this cat in a round about sort of way.

Here's what I did to get a list of tickers from an outside source 
into a watchlist in AmiBroker:

1. Save list in file ZacksTop.csv (It's from Zacks and is their Top 
Rank).
2. I modified a JScript routine to read the file and place tickers 
into group 10 in AMI (You can modify the script to change this 
another groupID if you like).
3. Run the Script.
4. Start Automatic Analysis
5. Enter this as your Exploration:

filter = 1;
numcolumns = 1;

6. Use a filter of stocks in Group 10
7. Set your range and press Explore
8. Right Click on the results and add your results to a watch 
list!!!!!!


Here's the Jscript routine:

/*
** File:	Copy Ticker list to Group 10 List
** Created: Brett Forrester, June 09, 2001
** Purpose: Assign Tickers to Group List 10 in lieu of Watch List
** Language:	JavaScript (Windows Scripting Host)
**
** The data is stored in lines with following format
** <ticker>
**
*/

WScript.Echo( "Script Started" );

/* change this line according to your data file name */
ImportStocks("ZacksTop.csv");

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 ] ); 

/* This line assigns the stock to Watch List 
0 */
stock.GroupID = 10;

}
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();

}

Happy Watch Listing to all,

Brett


--- In amibroker@xxxx, "Tomasz Janeczko" <tj@xxxx> wrote:
> Hi Steve,
> 
> There is no such property yet.
> 
> Best regards,
> Tomasz Janeczko
> ===============
> AmiBroker - the comprehensive share manager.
> http://www.amibroker.com
> 
> ----- Original Message ----- 
> From: brett_f1@xxxx 
> To: amibroker@xxxx 
> Sent: Saturday, June 09, 2001 8:09 PM
> Subject: [amibroker] WatchList Import Question
> 
> 
> Does anyone know of a method to import a list of tickers in 
a .csv 
> file and assign them to a watchlist ? Or, in more technical 
terms, 
> what is the name of the property in the stock class that I can 
use to 
> write a Script routine to do this?
> 
> Brett
> 
> PS I will share the routine if someone can help with the property 
> name I need.
> 
> 
> Yahoo! Groups Sponsor 
> www. 
> 
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.