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

[amibroker] A Profitable Indicator



PureBytes Links

Trading Reference Links

Opps, Big bug in that code.

I forgot to close the file in the function.......... I do sugest you fix 
this before trying this code.

Here is new code, Untested.



/*
** AmiBroker/Win32 script.
**
** File:	
** Updated:	January 18th, 2004
** Purpose:	
** Language:	JavaScript (Windows Scripting Host)
**
** The data is stored in lines with following format
**
**
*/

/* change this line according to your data file name */
base = "am200401/am200401";
STicker = "GOLD";
/* Output file is STicker.csv */


WScript.Echo( "Ticker Find Started" );

var fso, fw, f, r;
var FName, outfile;
var ForReading = 1;
var ForWriting = 2;
var ForAppending = 8;

/* Create file system object */
fso = new ActiveXObject( "Scripting.FileSystemObject" );

outfile = STicker + ".csv";
fw = fso.OpenTextFile( outfile, ForAppending, false);

for( L1 = 1; L1 < 34; L1++ )
{
basename = base;
if (L1 < 10)
	{
	 basename = basename + "0";
	}
FName = basename + (L1)+".prn";
ImportStocks(FName);
}
fw.Close();

WScript.Echo( "Ticker Find Finished" );


function ImportStocks( filename )
{
	var fields;
	var ticker;

	try
	{
	
	/* open ASCII file */
	f = fso.OpenTextFile( filename, ForReading);

	/* read the file line by line */
	while ( !f.AtEndOfStream )
		{
		r = f.ReadLine();

		/* split the lines using comma as a separator */
		fields = r.split(",");
		
		ticker = fields[0];
		if (ticker == STicker)
  			{
			 fw.WriteLine( r );
			}
		}
	}
	catch ( e )
  	{
	
  WScript.echo( "There is a problem in file no." + L1 + ".\n"+ filename + 
"\nIt will be skipped and next file will be processed as normal" );
	
	}
f.close()
}




Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
     amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/