Home » Amibroker

Backup you Amibroker EOD Database in CSV Format

25 November 2009 366 views One Comment

Backup your Amibroker Database

I was trying to search an option which will export the data from AmiBroker to a folder where the data will be stored in seperate csv sheets. Here is a simple trick to export your Amibroker EOD Database to CSV Format. For eg. Nifty will be stored in a sheet where the data will be there from the date specified in the Automatic Analysis window to the date specified in Automatic Analysis window
AFL Code for Exporting to CSV
fh = fopen( “c:\\AmiBackup\\”+Name()+”.csv”, “w”);
if( fh )
{
fputs( “Ticker,Date,Open,High,Low,Close,Volume \n”, fh );
y = Year();
m = Month();
d = Day();
//r = Hour();
//e = Minute();
//n = Second();

for( i = 0; i < BarCount; i++ )
{
fputs( Name() + “,” , fh );
ds = StrFormat(“%02.0f-%02.0f-%02.0f,”,
y[ i ], m[ i ], d[ i ] );
fputs( ds, fh );

//ts = StrFormat(“%02.0f:%02.0f:%02.0f,”,
//r[ i ],e[ i ],n[ i ] );
//fputs( ts, fh );

qs = StrFormat(“%.4f,%.4f,%.4f,%.4f,%.0f\n”,
O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] );
fputs( qs, fh );
}

fclose( fh );
}

Buy = 0;
Steps to Backup your Data
1)Save the Export to CSV AFL Code to C:\Program Files\AmiBroker\Formulas\Custom path
2)Create a Folder Name “Amibackup” in C:\ Drive
3)Open Amibroker ->Analysis-> Automatic Analysis
4)Select All Symbols option from the Apply to coloumn and All Quotatios from the Range Column
you can also select specific Stocks by selecting the suitable options from the Apply to Column
5)Run SCAN
6)Amibroker Database converts to individual .csv file
Download the AFL code
Here the limitation is that you cannot specifiy the range of Date. By Default it will download from starting date to
ending date

Related Posts:

Most Commented Posts

Written by: Rajandran R

diggdelicious-buttonstumbleuponTechnoratiFacebookNewsvineRedditYahoo
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

One Comment »

  • Lokanath said:

    Great code

    thank you

    I cud backup my ami data

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.

Optionally add an image (JPEG only)