Expert Advisors: Quotes Monitoring (memory-mapped file) - page 2

 
sergeev:

1) only the server has the right to modify the memory. clients read it.

2)- look at Pipe. there the "events" of data arrival are implemented as self-explanatory - you have data, we take it, we wait for it.

3)yes, you will have to write a server or copy it from MSDN, but ready-made clients can be used directly in MQL5.

4) unfortunately, you can't solve this problem with the polling periodicity. Sleep(1) should not make noise even when working with memory. You should check the timing of functions, maybe there are extra passes and load somewhere.

1 - only a server (written by me from your work)

2 - interesting, I will look only I have a task "as timely as possible" to transfer data 4(8) bytes, i.e. the whole cycle (must be performed very often)

3 - I think by analogy with the article I will make my own, but so far the problem even the test example does not work.

4 - yes, I rewrote some things optimised the code, it seems to be better.

 

I tried to add your dll to mt4.

2013.04.01 00:03:49     _tradeBuySell_mt4 GBPCHF,H1: -unknow err(0)  h=0
2013.04.01 00:03:49     _tradeBuySell_mt4 GBPCHF,H1: function 'MemOpen' call from dll 'MemMap32.dll' critical error c0000005 at 666013E6.
Here is the code
#include <stdlib.mqh>

#define modeOpen                                                        0 // open flag
#define modeCreate                                                      1 // creation flag

#import "MemMap32.dll"
int MemOpen(string path,int size,int mode,int &err); // open/create file in memory, get handle
void MemClose(int hmem); // close the file in memory
int MemGrows(int hmem,string path,int newsize,int &err); // increase the size of the file in memory
int MemWrite(int hmem,int &v[], int pos, int sz, int &err); // write int(4) vector v to memory from the specified position pos, size sz
int MemRead(int hmem, int &v[], int pos, int sz, int &err); // read vector v from the specified position pos with size sz

#import


int hmem,err; // 
string file; // file name in memory


int init()
   {
   file="Local\\123"; // file name in memory

   hmem=MemOpen(file,-1,modeOpen,err); // open an existing file
   if(hmem>0) // if opened
     {
      Print("open OK h="+hmem);
     }
   else
   if(err==-2) // if not opened,
     {
      Print("-err("+err+") memfile not found.");

     }
   else
     {
      Print("-unknow err("+err+")  h="+hmem);
      return(0);
     }
   Print("OK ("+err+") h="+hmem);   
 
      return(0);
   }
 

turn the screwdriver right

 
sergeev:

turn the screwdriver correctly

Your example in the link uses MemMap.dll

It is not there, it is MEmMap32.dll.

It works in mt5, but in mt4 it doesn't find the file.

Initially incorrectly declared err should have been an array, thanks for that

 
Can you tell me how to bypass this?
OK      1       01:10:31        tradeBuySell    'D:\MT5******\MQL5\Libraries\MemMap32.dll' is not 64-bit version
JF      1       01:10:37        tradeBuySell (GBPUSD,H1)        Cannot load 'D:\******\MQL5\Libraries\MemMap32.dll'

The x64 version of terminal mt5 is automatically installed on the server.

I have Win7x64 on my laptop, but I have a regular 32-bit version of terminal and it does not try to update to x64 itself.