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

[amibroker] Export to csv file



PureBytes Links

Trading Reference Links

Hi.
I want to export quotes to csv file in Amibroker 4.8 and the following
txt file is open but the export tool is not function.
How could I export quotes?

/*
** AmiBroker/Win32 scripting Example
**
** File:	Export.js
** Created:	Tomasz Janeczko, December 12th, 1999
** Purpose:	Exports quotations to CSV file
** Language: 	JScript (Windows Scripting Host)
*/

function FormatFloat( number )
{
	number = 0.001 * Math.round( number * 1000 );
	str = number.toString();

	return str.substring( 0, str.indexOf(".") + 4 );
}

var oAB = WScript.CreateObject("Broker.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");

var oStocks = oAB.Stocks;

Ticker = oAB.ActiveDocument.Name;

oStock = oStocks( Ticker );

var Qty = oStock.Quotations.Count; 

WScript.Echo("Export of " + Ticker + " start" );

f = fso.OpenTextFile( Ticker + ".csv", 2, true );

f.WriteLine("$SEPARATOR ,");
f.WriteLine("$FORMAT Ticker,Date_YMD,Open,High,Low,Close,Volume")

for( i = 0; i < Qty; i++ )
{
	oQuote = oStock.Quotations( i );

	var oDate = new Date( oQuote.Date );

	f.WriteLine( 	oStock.Ticker + "," + 
			oDate.getFullYear() + "-" + (oDate.getMonth()+1) + "-" +
oDate.getDate() + "," + 
			FormatFloat( oQuote.Open ) + "," + 
			FormatFloat( oQuote.High ) + "," +
			FormatFloat( oQuote.Low ) + "," +
			FormatFloat( oQuote.Close ) + "," + 
			Math.round( oQuote.Volume )  );
}

f.Close();

WScript.Echo("Export finished" );





------------------------ Yahoo! Groups Sponsor --------------------~--> 
GFT Forex Trading Accounts As low as $250 with up to 400:1 Leverage. Free Demo.
http://us.click.yahoo.com/lpv1TA/jlQNAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.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/