March 4, 2006
How to export quotations from AmiBroker to 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 the Formula 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 press OK
Filed by Tomasz Janeczko at 8:56 pm under Data,Exploration
6 Comments
From experience of this if you intend to import this data back into Amibroker, you need to make certain your windows date and time formats are compatible with the AB ascii import formats. eg time to be in 24 hour clock
Yes that’s true, 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")
is there anyway to export all datas to Metastock format ?
You can not export to Metastock directly, but you can export to text file and later use Equis Downloader to import text files to Metastock.
[…] 1) Export quotations from one database to the ASCII files and reimport quotes from another database (export procedure is described in the following article in the Knowledge Base http://www.amibroker.com/kb/2006/03/04/how-to-export-quotations-from-amibroker-to-csv-file/ ) […]
How to separate day/time column to day column and time column? eg. 10-10-07 10:30 to 10/10/07 and 10:30