My EA automatically exports the OHLC information from the last closed candle to a txt file. Then, another different program reads that txt file. So I think I must use share_read and share_write instead of FILE_READ or FILE_WRITE, right?
Do I need to modify the code of the external program (written in Visual Basic Net) to access the txt file or if I modify the code of the EA using FILE_SHARE_WRITE OR FILE_SHARE_READ is enough?
The idea is 'OnBarOpen' (in EA) the EA writes the OHLC values to a text file. The VB programs need as soon as possible the information written in that text file to perform several actions. Until this moment, I coded VB program to access the text file each n*5+1 minutes. I am working on M5 time period in MT4, so the txt file gets updated at 5, 10, 15, 20, 25, 30... minutes and the VB program access at 6, 11, 16, 21, 31... minutes to the text file, but I am spending almost a minute. I mean, I think the VB program can access the txt file (only to read the values) sooner than 1 minute after each 5-minute multiples.
Hello,
Be careful, one should declare both FILE_READ and FILE_SHARE_READ (for WRITE as well),
Concerning the VB stuff, I do not know about VB, but I guess if the file is first opened from Meta Trader there should be no problem,
As for the timing, I am not sure what you mean, are you looking for ways to sync both programs?
Hello,
Be careful, one should declare both FILE_READ and FILE_SHARE_READ (for WRITE as well),
Concerning the VB stuff, I do not know about VB, but I guess if the file is first opened from Meta Trader there should be no problem,
As for the timing, I am not sure what you mean, are you looking for ways to sync both programs?
So, do you mean that I need to declare both FILE_SHARE_READ and FILE_SHARE_WRITE? Why? It happens the same if I declare FILE_READ? I mean if I need to declare read and write when using FILE_READ instead of FILE_SHARE_READ. Thanks.
So, do you mean that I need to declare both FILE_SHARE_READ and FILE_SHARE_WRITE? Why? It happens the same if I declare FILE_READ? I mean if I need to declare read and write when using FILE_READ instead of FILE_SHARE_READ. Thanks.
Well, if e.g. you wanted to share read from a file, you can not specify FILE_SHARE_READ alone, but you have to include FILE_READ as well. That means the line should be FILE_READ|FILE_SHARE_READ. Same goes for share write.
Well, if e.g. you wanted to share read from a file, you can not specify FILE_SHARE_READ alone, but you have to include FILE_READ as well. That means the line should be FILE_READ|FILE_SHARE_READ. Same goes for share write.
Oh, I better understand right now.
You mean that FILE_SHARE_READ never should be alone. So the correct way is FILE_READ|FILE_SHARE_READ, right?
Oh, I better understand right now.
You mean that FILE_SHARE_READ never should be alone. So the correct way is FILE_READ|FILE_SHARE_READ, right?
yep, this is it. I reckon, the documentation may not be very clear at times, especially if someone is reading in a hurry, but this is MetaQuotes' way :) For the record here are the docs https://www.mql5.com/en/docs/constants/io_constants/fileflags

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I am just programming an EA and I have been reading the documentation I found: https://docs.mql4.com/files/fileopen
As far I know (I am not an experienced programmer), FILE_SHARE_WRITE (or share read) must be used when a file is accessed from multiple programs, right?
My EA automatically exports the OHLC information from the last closed candle to a txt file. Then, another different program reads that txt file. So I think I must use share_read and share_write instead of FILE_READ or FILE_WRITE, right?
Do I need to modify the code of the external program (written in Visual Basic Net) to access the txt file or if I modify the code of the EA using FILE_SHARE_WRITE OR FILE_SHARE_READ is enough?
The idea is 'OnBarOpen' (in EA) the EA writes the OHLC values to a text file. The VB programs need as soon as possible the information written in that text file to perform several actions. Until this moment, I coded VB program to access the text file each n*5+1 minutes. I am working on M5 time period in MT4, so the txt file gets updated at 5, 10, 15, 20, 25, 30... minutes and the VB program access at 6, 11, 16, 21, 31... minutes to the text file, but I am spending almost a minute. I mean, I think the VB program can access the txt file (only to read the values) sooner than 1 minute after each 5-minute multiples.
What do you recommend to do in this case?
Thanks.