#EOD-Data export script
Tomasz Janeczko described -- in AmiBroker kb -- a simple way to export AB data to a .csv
file.
The easiest way to export quotes to CSV file is to use the below formula from Automatic Analysis window:
(Analysis -> Automatic Analysis)
Filter=1;
AddColumn(O,"Open");
AddColumn(H,"High");
AddColumn(L,"Low");
AddColumn(C,"Close");
AddColumn(V,"Volume",1.0);
AddColumn(OI,"Open Interest",1.0);
- Open:
Analysis->Formula Editor
- Paste the above formula into formula window
- Choose
Tools->Send to Auto-Analysis
menu in theFormula Editor
- In Automatic Analysis window select
Apply to: All Stocks
,Range: All quotations
(or any other time range or filter, depending on what you need to export) - Press
Explore
button - Press
Export
button, specify the name and pressOK
Tomasz also described in a reply to a comment to the above script that --
"... this code sample was designed to be easy and output was not intended to be re-imported to AmiBroker. There are other ways to export of course, including using file functions as shown in the code below that does what you asked for (exports date in fixed YYMMDD format and times in HHMMSS 24-hour format)."
fh = fopen( "DataFor"+Name()+".csv", "w" );
if( fh )
{
fputs("Symbol,Date,Time,Open,High,Low,Close,OpenInt,Volume\n", fh );
dn = DateNum();
tn = TimeNum();
for( i = 0; i < BarCount; i++ )
{
Line = Name() +
StrFormat(",%06.0f,%06.0f,%g,%g,%g,%g,%g,%g\n",
dn[ i ] % 1000000,
tn[ i ],
Open[ i ],
High[ i ],
Low[ i ],
Close[ i ],
OpenInt[ i ],
Volume[ i ] );
fputs( Line, fh );
}
fclose( fh );
}
Buy=Sell=0; // for scan
Filter = Status("lastbarinrange");
AddTextColumn("Export done", "Status");
Checkout another primitive version of this kind of script in my collection
Hope this collection helps all in exporting AB EOD-Data. Happy trading!!