File Operations?

 

Hi,

I m trying to read back the information from a CSV file. The format of the CSV file is shown as below

Ticket; Open Time; Type; Lots; Item; Price; SL; TP; Close Time; Price;
13953649;2008.05.30 22:36;Buy;0.10;GBPJPY;209.18;0.00;0.00;2008.05.30 22:47;209.18;

13953303;2008.05.30 22:02;Buy;0.10;EURGBP;0.7854;0.0000;0.0000;2008.05.30 22:49;0.7848;
13953302;2008.05.30 22:02;Buy;0.10;EURJPY;164.04;0.00;0.00;2008.05.30 22:47;164.17;

What I want to achieve is I would like to check whether the order ticket I m searching for is inisde this file,

if it does ( let say the ticket i m seaching is 13953303),then it will go to extract the trade details( SL,TP etc) of this ticket.

if it doesn't exist, it will go to read the next ticket from the new line without go through the trade details on the same line.

Currently the MQL4 FileReadString(Handle) function will loop through all the elements separated by comma, it is wasting processing time if my CSV file is large.

Does anyone has an idea of how to skip to read the rest of the element on the same line if the Ticket is not matched

Thanks Much

Tom

 

methinks is total knife 'n fork job.

no way to 'know' where EOL offset is, next record starts etc.


you could consider opening file in FILE_BIN|FILE_READ mode.

then use FileReadArray(handle,stringArray,0,10)

int = StrToInteger(stringArray[0])

if int equals ticket# then process...

else try next line etc.

stringArray[] used because only data type which would allow you to call FileReadArray() once per line.


I tested out and does work and end up with 10 elements each with one datum...


But...strangely the condition: FileIsEnding(handle) always returned true the second time around the while loop so only able to read/convert/match first line


I have NO clue as to why the EOF builtin not keep returning false until last line read in.

maybe FileReadArray() builtin actually sucks in all? not know - requires research = trial and error

no more time to spend on this.


have fun.

 
ukt:

methinks is total knife 'n fork job.

no way to 'know' where EOL offset is, next record starts etc.

you could consider opening file in FILE_BIN|FILE_READ mode.

then use FileReadArray(handle,stringArray,0,10)

int = StrToInteger(stringArray[0])

if int equals ticket# then process...

else try next line etc.

stringArray[] used because only data type which would allow you to call FileReadArray() once per line.


I tested out and does work and end up with 10 elements each with one datum...


But...strangely the condition: FileIsEnding(handle) always returned true the second time around the while loop so only able to read/convert/match first line

I have NO clue as to why the EOF builtin not keep returning false until last line read in.

maybe FileReadArray() builtin actually sucks in all? not know - requires research = trial and error

no more time to spend on this.


have fun.

Hi ukt

Thanks for your info.

 
TT_FX1:

Hi,

I m trying to read back the information from a CSV file. The format of the CSV file is shown as below

Ticket; Open Time; Type; Lots; Item; Price; SL; TP; Close Time; Price;
13953649;2008.05.30 22:36;Buy;0.10;GBPJPY;209.18;0.00;0.00;2008.05.30 22:47;209.18;

13953303;2008.05.30 22:02;Buy;0.10;EURGBP;0.7854;0.0000;0.0000;2008.05.30 22:49;0.7848;
13953302;2008.05.30 22:02;Buy;0.10;EURJPY;164.04;0.00;0.00;2008.05.30 22:47;164.17;

What I want to achieve is I would like to check whether the order ticket I m searching for is inisde this file,

if it does ( let say the ticket i m seaching is 13953303),then it will go to extract the trade details( SL,TP etc) of this ticket.

if it doesn't exist, it will go to read the next ticket from the new line without go through the trade details on the same line.

Currently the MQL4 FileReadString(Handle) function will loop through all the elements separated by comma, it is wasting processing time if my CSV file is large.

Does anyone has an idea of how to skip to read the rest of the element on the same line if the Ticket is not matched

Thanks Much

Tom

Hi,

I'm a new user can any one teach me to close a trade in either mode "buy" or "sell" when the pricing reached our needs in a "live mode" ?

 
yurazak:
TT_FX1:

Hi,

I m trying to read back the information from a CSV file. The format of the CSV file is shown as below

Ticket; Open Time; Type; Lots; Item; Price; SL; TP; Close Time; Price;
13953649;2008.05.30 22:36;Buy;0.10;GBPJPY;209.18;0.00;0.00;2008.05.30 22:47;209.18;

13953303;2008.05.30 22:02;Buy;0.10;EURGBP;0.7854;0.0000;0.0000;2008.05.30 22:49;0.7848;
13953302;2008.05.30 22:02;Buy;0.10;EURJPY;164.04;0.00;0.00;2008.05.30 22:47;164.17;

What I want to achieve is I would like to check whether the order ticket I m searching for is inisde this file,

if it does ( let say the ticket i m seaching is 13953303),then it will go to extract the trade details( SL,TP etc) of this ticket.

if it doesn't exist, it will go to read the next ticket from the new line without go through the trade details on the same line.

Currently the MQL4 FileReadString(Handle) function will loop through all the elements separated by comma, it is wasting processing time if my CSV file is large.

Does anyone has an idea of how to skip to read the rest of the element on the same line if the Ticket is not matched

Thanks Much

Tom

Hi,

I'm a new user can any one teach me to close a trade in either mode "buy" or "sell" when the pricing reached our needs in a "live mode" ?

https://book.mql4.com/build/trading

Reason: