PureBytes Links
Trading Reference Links
|
This is example what I've done in export.js script:
/*
** AmiBroker/Win32 scripting Example
**
** File: ExportToASCII.js
** Created: D Stricek,
** Purpose: Exports quotations in corrected format for ASCII
*/
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 + ".txt", 2, true );
f.WriteLine
("<TICKER>,<DTYYYYMMDD>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>,")
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" );
And what I got:
<TICKER>,<DTYYYYMMDD>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>
^DJI,200051,10749.4,11001.300,10622.2,10811.800,120942112
^DJI,200052,10805.6,10932.5,10580.6,10731.1,171903600
^DJI,200053,10732.2,10754.4,10345.2,10480.1,180518112
Should be:
<TICKER>,<DTYYYYMMDD>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>
^DJI,20000501,10749.4,11001.300,10622.2,10811.800,120942112
^DJI,20000502,10805.6,10932.5,10580.6,10731.1,171903600
^DJI,20000503,10732.2,10754.4,10345.2,10480.1,180518112
Drazen
|