|
print(TO_CSV,...) too slow?
#475718
01/05/19 00:25
01/05/19 00:25
|
Joined: Sep 2016
Posts: 26 London - Prague - Kho Yao Noi
Sinuhet
OP
Newbie
|
OP
Newbie
Joined: Sep 2016
Posts: 26
London - Prague - Kho Yao Noi
|
Hi all I would like to export some data as recommended by JCL here. The export of 1min 1 year 1 forex pair OHLC data takes 2 to 3 minutes depending which from the below codes I use. This is the time needed to write the CSV file with some 358636 rows (1 min data of EURUSD for 2013) and 6 columns. This AFTER I turned off the Windows Defender on Windows 10 (otherwise it takes about an hour). Can I optimise the speed of print(TO_CSV,...) ? I am asking since the same task takes ZHistoryEditor about 8 sec. Also the Multicharts are significantly faster in the CSV export. Thx for help Code 1 (2 mins):
function run()
{
BarPeriod = 1;
StartDate = 2013;
EndDate = 2013;
LookBack = 0;
print(TO_CSV,"%02i/%02i/%02i %02i:%02i, %.5f, %.5f, %.5f, %.5fn",
day(),month(),year(),hour(),minute(),
priceOpen(),priceHigh(),priceLow(),priceClose());
}
Code 2 (3 mins):
function run()
{
BarPeriod = 1;
StartDate = 2013;
EndDate = 2013;
LookBack = 0;
string line = strf(
"%02i/%02i/%02i %02i:%02i, %.5f, %.5f, %.5f, %.5fn",
day(),month(),year()%100,hour(),minute(),
priceOpen(),priceHigh(),priceLow(),priceClose());
if(is(INITRUN))
file_delete("Dataexport.csv");
else
file_append("Dataexport.csv",line);
}
Last edited by Sinuhet; 01/05/19 00:38.
|
|
|
Re: print(TO_CSV,...) too slow?
[Re: Spirit]
#475837
01/09/19 19:56
01/09/19 19:56
|
Joined: Sep 2016
Posts: 26 London - Prague - Kho Yao Noi
Sinuhet
OP
Newbie
|
OP
Newbie
Joined: Sep 2016
Posts: 26
London - Prague - Kho Yao Noi
|
Thank you Spirit indeed that what I have done, but still cannot get the output right (getting a CSV only 1 row of data for the 31.12.2013). Any idea what is wrong with my code?
function run()
{
BarPeriod = 1;
StartDate = 20130101;
EndDate = 20131231;
LookBack = 0;
string line = strf("%02i/%02i/%02i %02i:%02i, %.5f, %.5f, %.5f, %.5fn",
day(),month(),year()%100,hour(),minute(),
priceOpen(),priceHigh(),priceLow(),priceClose());
if(is(INITRUN))
file_delete("Data\\export.csv");
else
char str[50000];
strcat(str,line);
if(is(EXITRUN))
file_write("Data\\export.csv",str,0);
}
Last edited by Sinuhet; 01/09/19 22:59.
|
|
|
|