You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
it's not called closing the record, it's called closing and deleting the file.
which is why
you are trying to open something that doesn't exist anymore.Looking through the library code I saw that the file is deleted not only when the Close() function of the CMemMapFile class is called directly, but also when the pointer to the object of this class is deleted, because this function is called in the class destructor. I am a bit perplexed. It turns out that the dynamic method of creating class objects cannot be used if writing and reading a file are used in different calling contexts (scopes). For example, one chart of the terminal writes data to a file, the second reads data and deletes this file. It turns out that the object variable should always be kept at the global level, so that the file is not forcibly deleted. It is also not clear whether it is possible to do without specifying the size of the read data. That is, we know the size of the data when writing it, but when reading it on another chart we may not know the size of the data in advance, as for example in the case of string values. Probably either I have misunderstood something or there is something else to tweak in the library.
My bad. I rechecked it without using the pointer and therefore without using delete. In this case, when leaving the scope (from a function), the local variable of the class object is destroyed without an explicit call to the destructor.
There is still a question about the size of received data on the receiver's side.
Thanks to the author for the library!
I made functions for transferring any data. The script below shows their work on the example of ticks
Result
Super! By analogy with your code I simplified the use of the library for myself.
Forum on trading, automated trading systems and testing trading strategies
NamedPipes for metatrader 4
fxsaber, 2017.11.30 14:18
Exchange_Data.mqh
PriceGiver.mq4
PriceTaker.mq4
Run PriceGiver.ex4 and PriceTaker.ex4.
Result
The library has a small error in the CMemMapFile::Open method. It should return the file handle (type HANDLE64), but instead it returns 0 or an error code.
In addition, the read and write methods CMemMapApi::Write and CMemMapApi::Read for some reason double recopying of data (and bytes are looped through!), and in addition the file is overwritten/read in its entirety, although only a specified piece is required.
In general, I've made them look normal, the unnecessary stuff is commented out :
To make the first function compile, you need to set const for arrays in memcpyX and memcpy functions, which the author didn't bother to set.Error when copying large sizes, due to zero being passed in dwMaximumSizeHigh
Fixed it like this:
This size - 6 mb, transfers without problems:
Corrected it like this:
Properly pass the high 4 bytes of the 8-byte size there.
Ok, now we have all the raites in the C# program and we can analyse everything we need using LINQ.
But there is a question, how to organise the mechanism of commands between the terminal and the application.
From the terminal: new candle, new raites - take the file
From the application: calculation completed, take the result (draw on the chart, open a deal).
Does anyone have experience in such implementation of interaction between terminal and code?
Ok, now we have all the raites in a C# program and can use LINQ to analyse everything perfectly.
But there is a question, how to organise the mechanism of commands between the terminal and the application.
From the terminal: new candle, new rates - get the file
From the application: calculation completed, take the result (draw it on the chart, open a deal).
Does anyone have experience with such implementation of interaction between terminal and code?
Please advise what to do in this situation.
1. I opened a new file in memory with 100 bytes.
2. I wrote 100 bytes to it.
3. I read 100 bytes in another Expert Advisor. Everything is fine.
4. Now how to write 50 or 200 bytes to the same file?