Last active
November 30, 2019 04:57
-
-
Save marketcalls/fc2ec94f69096ccbea22fd566cfb2635 to your computer and use it in GitHub Desktop.
Export Amibroker Data to Ninjatrader EOD or 1min ASCII format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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[i] = abs(r[i]-6 + int((e[i]+30) / 60)) % 24; | |
e[i] = (e[i]+ 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[i]); | |
o1 = StrFormat("%.2f",O[i]); | |
h1 = StrFormat("%.2f",H[i]); | |
l1 = StrFormat("%.2f",L[i]); | |
v1 = StrFormat("%.0f",V[i]); | |
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment