help:delete the information from txt - page 2

 

Do you want to:

1. Truncate the file - clear it out - make it empty - 0 bytes. ?

 OR

2. Rename the name?

OR

 3. Deleted only the information that was read from the file - but it looks like you are reading all of it so that would be the same as 1. ?

 

 3. Deleted only the information that was read from the file - but it looks like you are reading all of it so that would be the same as 1.

i want just read one information After that delete information

 

And how does the information come into the file ? Does the file get more information from somewhere else while the EA is running?

Deleting from the beginning of a file is not efficient nor easy -  better option might be to keep the file open all the time - and just read  the next lot of information on the next tick. - FileOpen in OnInit , FileClose in OnDeInint...

 but if the file is being updated from another source at the same time look at shared files, or name pipes

 Also think about how much information is read for each tick?

 
i want to read one information every tick and when finish delete the content after that Repeat the process every Tick
 
ayoub:
i want to read one information every tick and when finish delete the content after that Repeat the process every Tick

Repeat what?

If you have deleted the content, then the next tick there is nothing to read. 

ydrol already asked you..... 

ydrol:

And how does the information come into the file ?

 

Sorry I cant help much more without answers to earlier questions. Reading a single line and deleting every tick sounds like a bad design. Just keep the file open all the time and read the next record. 

Your earlier code also looked like it was reading the entire file in one go. Change it to only read one item ? 

 
Indeed. Opening, Deleting and then Closing a file every tick is a bad idea. This will result in heavy I/O on the filesystem. Specially if you run other things in the background or do bigger file movements, then this will probably give bad performance. Also think about the "tick" itself. On real volatile days e.g. when price movement goes up and down withing a short period then you might be getting plenty of ticks in a short period. Now imagine this not only with 1 chart open but with 10 charts running simultaneously.
 
aakcaagac:
Indeed. Opening, Deleting and then Closing a file every tick is a bad idea. This will result in heavy I/O on the filesystem. Specially if you run other things in the background or do bigger file movements, then this will probably give bad performance. Also think about the "tick" itself. On real volatile days e.g. when price movement goes up and down withing a short period then you might be getting plenty of ticks in a short period. Now imagine this not only with 1 chart open but with 10 charts running simultaneously.
I second this.  Unless the information you are reading is saved to a larger file, and you are only reading the last entry when it was made, there really is no reason to save the information to a file, just to read it back out and delete the info.  Even if you are not deleting the file every time, but saving the info to the same file every time, it does put a huge load on the system, which will result in more time spent doing this than the program could be spending doing something better, like maybe making you more money.  If you can limit what the program has to do to the bare minimum past what you want and/or need it to do, the better.  This saves in a couple of ways.  First is the system resources.  A computer system that is only running a program that needs 50% of it's resources will usually run a lot faster than a program that needs to use 100+%, that extra being whatever, file I/O, computations, whatever.  Second, it also saves debugging time because there is less code for something to possibly go wrong, and there is less code to have to look through if something DOES go wrong.
Reason: