bellow mention export afl from ami to csv filr, but its EoD, can you help me to modify intrday time frame 1 min

pareshR

Well-Known Member
#1
Hello

bellow mention export afl from ami to csv filr, but its EoD, can you help me to modify intrday time frame 1 min

thx
paresh


// From: http://www.amibroker.com/library/detail.php?id=1129
// By Barry Scarborough 7/14/2008, updated to handle large files 8/30/08

// #### READ THIS FIRST #### READ THIS FIRST #### READ THIS FIRST #### READ THIS FIRST #### READ THIS FIRST ####
// Export intraday and EOD data to .csv files
// One file for each stock but the symbol name must be a valid Microsoft file name or you will have to modify it, see code below to change name
// if the data exceeds 65500 lines it will be broken into separate files up to 327,500 lines or about 227 days of 24 hour, one minute data
// This will create a directory C:\AmiBackup
// Select your symbols to export with the "Apply to" filter in AA window, to save data base use all symbols and all quotes
// Make sure the chart is on the period you want to save
// Select the same timeframe period you want to save as using the AA "Settings"
// Press Scan button
//

// created a directory on your C drive named AmiBroker data backup
dayhours = ParamToggle("Day hours only", "No|Yes");
fmkdir("c:\\AmiBackup\\");
SetBarsRequired(100000,100000);
lname = Name(); // gets the name of the symbol
// note: if you have names with invalid characters like / you must rename the file before you try to create a name
// add an IF line for each symbol you need to rename
if (lname == "ER2U8-GLOBEX-FUT") lname = "ER2U8";

fh = fopen( "c:\\AmiBackup\\" + lname + ".csv", "w");
if( fh )
{
if(Interval() == inDaily OR Interval() == inMonthly OR Interval() == inWeekly)
{
fputs( "Ticker,Date,Open,High,Low,Close,Volume \n", fh );
for( i = 0; i < BarCount; i++ )
{
y = Year();
m = Month();
d = Day();
fputs( Name() + "," , fh );
ds = StrFormat("%02.0f-%02.0f-%02.0f,", m[ i ], d[ i ], y[ i ] );
fputs( ds, fh );
qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n", O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] );
fputs( qs, fh );
if(i == 65500 OR i == 130000 OR i == 196500 OR i == 262000)
{
fclose( fh );
if(i == 65500 ) fh = fopen( "c:\\AmiBackup\\" + lname + " A.csv", "w");
if(i == 130000 ) fh = fopen( "c:\\AmiBackup\\" + lname + " B.csv", "w");
if(i == 196500 ) fh = fopen( "c:\\AmiBackup\\" + lname + " C.csv", "w");
if(i == 262000 ) fh = fopen( "c:\\AmiBackup\\" + lname + " D.csv", "w");
}
}
}
else // intraday so add time field
{
fputs( "Ticker,Date,Time,Open,High,Low,Close,Volume \n", fh );
y = Year();
m = Month();
d = Day();
r = Hour();
e = Minute();
n = Second();

for( i = 1; i < BarCount; i++ )
{
if (dayhours AND LastValue(TimeNum()) >= 92900 AND LastValue(TimeNum()) <= 161500)
{
fputs( Name() + "," , fh );
ds = StrFormat("%02.0f-%02.0f-%02.0f,", m[ i ], d[ i ], y[ 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 );
}
else
{
fputs( Name() + "," , fh );
ds = StrFormat("%02.0f-%02.0f-%02.0f,", m[ i ], d[ i ], y[ 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 );
}
if(i == 65500 OR i == 130000 OR i == 196500 OR i == 262000)
{
fclose( fh );
if(i == 65500 ) fh = fopen( "c:\\AmiBackup\\" + lname + " A.csv", "w");
if(i == 130000 ) fh = fopen( "c:\\AmiBackup\\" + lname + " B.csv", "w");
if(i == 196500 ) fh = fopen( "c:\\AmiBackup\\" + lname + " C.csv", "w");
if(i == 262000 ) fh = fopen( "c:\\AmiBackup\\" + lname + " D.csv", "w");
}
}
}
fclose( fh );
}

Buy = 1;
 
#2
Dear if you have stored data in one minute time frame in your Ami database then in analysis window please set settings one minute. If still you Facing Problem Then Use this AFL . First Make a Folder AS Per Afl in c drive c:/SaveData.

/////////////////////////////////////////////////DATA IN TEXT FILE //////////////////////////////////////////////////
fh = fopen( "c:\\SaveData\\"+Name()+".txt", "w");
if( fh )
{
fputs( "Ticker,Date,Time,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 = C>0;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
Enjoy
Regards
 

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Name:Phone:
Email:City:
State:
Are you a day trader?