hi, I want to import CSV files using AFL. I searched and found solutions using scripting but I always get dizzy when I look at that, i think I am too dumb to use that. There is an example here:
http://www.amibroker.com/newsletter/02-2001.html
I understand the format needs to be known of the data to import. Anyone know how to do this from AFL. So I have the code below. As you can see I defined the file names. The format for all files is the same. Can this be done from AFL? Or do I need external scripting? Thanks
dataPath = "D:\\AmibrokerDataTest\\";
// date format %m-%d-%Y
startDate1 = ParamDate( "Start Date", "10/4/2022", 2 );
endDate1 = ParamDate( "End Date", "11/4/2022", 2 );
importprocessed1mindata = ParamTrigger( "Import 1Min Data in Amibroker Research DB", "Press Here" );
ndays = DateTimeDiff( endDate1, startDate1 ) / inDaily;
// set your symbol list here
symbollist = "[@ES#,@NQ#]";
if( importprocessed1mindata )
{
Say( "import 1 minute data" );
for( i = 0; ( sym = StrExtract( symbollist, i ) ) != ""; i++ )
{
for( i = 0; i < ndays; i++ )
{
n1 = DateTimeAdd( startDate1, i, inDaily );
n2 = DateTimeToStr( n1, 1 );
n2a = StrReplace( n2, "/", "," );
mm = StrExtract( n2a, 0 );
dd = StrExtract( n2a, 1 );
yyyy = StrExtract( n2a, 2 );
if( StrLen( mm ) == 1 )
{
mm = "0" + mm;
}
if( StrLen( dd ) == 1 )
{
dd = "0" + dd;
}
fdate = yyyy + mm + dd;
fn1 = dataPath + sym + "\\" + "1minMKTLMT\\" + sym + "_" + fdate + "_" + "1min" + ".csv";
fn2 = dataPath + sym + "\\" + "1minMKTLMT\\" + sym + "_" + fdate + "_Delta_" + "1min" + ".csv";
fn3 = dataPath + sym + "\\" + "1minMKTLMT\\" + sym + "_" + fdate + "_LMTDelta_" + "1min" + ".csv";
fn4 = dataPath + sym + "\\" + "1minMKTLMT\\" + sym + "_" + fdate + "_MKTDelta_" + "1min" + ".csv";
printf( "" + fn4 + "\n" );
}
}
Say( "finished" );
}
SetChartOptions( 1, chartShowDates, chartGridMiddle, 0, 0, 0 );
Plot( C, "Data", ColorRGB( 3, 157, 252 ), styleDots, Null, Null, 0, 0, 1 );