Reading a string date into a matrix

Hi guys,
firstly I recognise this is similar to a few other posts but I am missing something.

I am reading from an input text file as:-

from input file buyline
2019-09-23,AUT.AX,0.0055,100000,,

buyLine = fgets( buyFile );
buyDate = StrToNum(StrExtract( buyLine, 0 ));

buyCount = 1
loaded into matrix
buyTrades[buyCount][1] = buyDate;

then later retrieved to lookup barindex

I = 1
buyDate = DateTimeConvert(2, buyTrades[i][1]);
barI = Lookup( BarIndex(), buyDate );

I am obviously getting it wrong as barI is 0.

Hope this is not too simple as I have read quite a biy of the doco and form comments but it still eludes ne.

Cheers,

That code line will not create expected datetime number.

Instead to convert string to DateTime value use _DT() function:

buyDate = _DT(StrExtract( buyLine, 0 ));

Then you do not need conversion in addition.


BTW, please use code tags when inserting code.
It is mandatory rule.
Please read here:

1 Like

Thanks fxshrat,
that did the trick.
I'll try to remember you hint on the code tags.

Cheers.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.