How to Modify this AFL for Exporting Ami Database to ASCII in Ninja Format

#1
I have got this AFL from marketcll website. I want to change the a line in this code
symbol_name = StrReplace(StrReplace(Name(),"N.",""),"-I.NFO","");
in such way that after exporting the files will be created in the following simple manner like ABB.TXT, NIFTY.TXT, YESBANK.TXT. In the above code I understand it is for Future and Option. Thanks and Regards
The main code is as follows

//Coded By Paris Kamal
//Coder - www.marketcalls.in
//Date : 12th Jul 2017
_SECTION_BEGIN("Export Amibroker Data to Ninjatrader EOD or 1min ASCII format");
path = "C:\\amidata\\";
Filter = 1;
symbol_name = StrReplace(StrReplace(Name(),"N.",""),"-I.NFO","");
data_format = ParamToggle("format","Daily|Minute",defaultval=0);
if(data_format == 1)
{
path = path + "minute\\"+symbol_name+".txt";
}
else
{
path = path + "daily\\"+symbol_name+".txt";
}
lin = 0;
line = 0;
fh = fopen(path,"r");
if(fh){
while(!feof(fh))
{
fgets(fh);
line++;
}
fclose(fh);
}
printf("%f",line);
//yyyyMMdd;open price;high price;low price;close price;volume
for( i = 0; i < BarCount; i++ )
{
printf("%g",i);

if(i == 0){
fh = fopen(path,"w");
}
else
{
fh = fopen(path,"a");
}
if( fh )
{
y = Year();
m = Month();
d = Day();
ds = Null;
//s = gmtime;
//printf(s);
if(data_format == 1)
{
r = Hour();
e = Minute();
n = Second();
// convertion from ISO to GMT
r = abs(r-6 + int((e+30) / 60)) % 24;
e = (e+ 30) % 60;


ds = StrFormat("%02.0f%02.0f%02.0f %02.0f%02.0f%02.0f", y[ i ], m[ i ], d[ i ],r[ i ],e[ i ],n[ i ] );
}
else
{
ds = StrFormat("%02.0f%02.0f%02.0f", y[ i ], m[ i ], d[ i ] );
}
fputs(ds+";" ,fh );
//fputs("\""+"Date\""+": ISODate(\""+ ds+"\")," ,fh );
c1 = StrFormat("%.2f",C);
o1 = StrFormat("%.2f",O);
h1 = StrFormat("%.2f",H);
l1 = StrFormat("%.2f",L);
v1 = StrFormat("%.0f",V);
fputs(o1+";" ,fh );
fputs(h1+";" ,fh );
fputs(l1+";" ,fh );
fputs(c1+";" ,fh );
fputs(v1,fh );
fputs("\n",fh);
if(i!=BarCount-1)
{
fputs("\n",fh);
}
fclose( fh );
// fputs( qs, fh );

}
else
{
printf("\nfile not exists");
}


}

_SECTION_END();
 
Last edited:

Similar threads

Trade in Rs 20, No more % brokerage

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