dataFind() does not return the correct row for a timeperiod

Posted By: Tamas

dataFind() does not return the correct row for a timeperiod - 12/28/17 00:52

Hi, I am having trouble retrieving the correct row for a timeperiod in a dataset.
I am using dataParse to read in a csv file and then trying to find the corresponding row for the bar's timeperiod. Here is the code:

to read and parse:

string Format = "%Y-%m-%d %H:%M:%S,f";
int RecordsEUR1H = dataParse(1,Format,InNameEUR1H);

and then:

int RowEUR1H = dataFind(1,wdate());

it returns the attached for this print:
printf("n Date: %s, Row: %i, Value: %f",strdate("%Y-%m-%d %H:%M:%S",wdate()),RowEUR1H, dataVar(1,RowEUR1H,1));


My CSV file looks like this:
2017-12-28 00:00:00,-3.2885940290891
2017-12-27 23:00:00,-3.2924455825864
2017-12-27 22:00:00,-3.217172985187
2017-12-27 21:00:00,-2.26513041276
2017-12-27 20:00:00,-2.24
2017-12-27 19:00:00,-2.2688089773
2017-12-27 18:00:00,-2.22088050314
2017-12-27 17:00:00,-2.21020870003
2017-12-27 16:00:00,-2.28022255943
2017-12-27 15:00:00,-2.24341123819
2017-12-27 14:00:00,-2.16543756146
2017-12-27 13:00:00,-2.15416666667
2017-12-27 12:00:00,-2.11968734734
2017-12-27 11:00:00,-2.1027027027
2017-12-27 10:00:00,-2.06518554688
2017-12-27 09:00:00,-1.87034035656
2017-12-27 08:00:00,-1.89573570759
2017-12-27 07:00:00,-2.0331478345
2017-12-27 06:00:00,-1.98296136309
2017-12-27 05:00:00,-1.97462293512
2017-12-27 04:00:00,-1.88625146886
2017-12-27 03:00:00,-1.90072752875
2017-12-27 02:00:00,-1.89032106867
2017-12-27 01:00:00,-1.89953051643
2017-12-27 00:00:00,-1.87954066089
2017-12-26 23:00:00,-1.90943396226

It looks as if dataFind returns a record for every 2nd or so timeperiod BEFORE the given date? How can i make sure that it return a record for the exact timeperiod? data for that timeperiod is available in the dataset as you can see.

thanks for the help in advance.
I am using Zorro S 1.72 but tried it on S 1.66 and it is the same.

Attached picture Untitled.jpg
Posted By: Tamas

Re: dataFind() does not return the correct row for a timeperiod - 12/28/17 11:02

I have shifted the wdate() value with 1 second to go over the hour and now it finds the correct value based on the time just 1 second before that. so I overcome the above issue, but still would be interested to find out why the exact match with datafind does not work.
Posted By: jcl

Re: dataFind() does not return the correct row for a timeperiod - 12/28/17 11:40

I assume that wdate() was not exactly on a hour boundary, but still, the 1 second shift should normally not be necessary. Can you contact support(at)opgroup.de with your script and the CSV file? They'll look into it, maybe the problem is caused by something else.
Posted By: Tamas

Re: dataFind() does not return the correct row for a timeperiod - 12/28/17 13:27

thanks jcl, will drop them an email.
btw, how would you compare two DATE type variables to see if that are the same down to only the second? (no milliseconds or below)
Posted By: jcl

Re: dataFind() does not return the correct row for a timeperiod - 12/29/17 08:24

abs(Date1-Date2) < 1./(24*60*60)
© 2024 lite-C Forums