NamedPipes for metatrader 4

 

Hello,

Can someone share a simple client/server named pipes or other simple solution to exchange data between two metatrader 4 terminals?

I tested several scripts. None seem to work.

 
Hannan Nussbaum:

Can someone share a simple client/server named pipes or other simple solution to exchange data between two metatrader 4 terminals?

Here.

 
fxsaber:

I tried to compile it, it says problems in this line: CopyTicks(_Symbol, Ticks4Save, COPY_TICKS_INFO, 0, AMOUNT);

'COPY_TICKS_INFO' - undeclared identifier  

'CopyTicks' - function not defined  


 
This function is from MQL5 for example. Do not use it in MT4.
 

Do you have an example in MQL4?

 
Hannan Nussbaum:

Do you have an example in MQL4?

#define AMOUNT 1000

#define TOSTRING(A) #A + " = " + (string)(A) + " "

// Example of forwarding double array
void OnStart()
{    
  CMemMapFile* FileMemory;
  
  if (GetFileMemory<double>(FileMemory, AMOUNT))
  {
    double Array4Save[AMOUNT];    
    ArrayInitialize(Array4Save, 1.23456);
    
    DataSave(FileMemory, Array4Save);
    
    double Array4Load[];    
    
    if (DataLoad(FileMemory, Array4Load) > 0)    
      Print(TOSTRING((_R(Array4Save) == Array4Load)) +
            TOSTRING(ArraySize(Array4Save)) +
            TOSTRING(ArraySize(Array4Load)));
     
    FileMemory.Close();   
  }
  
  delete FileMemory;
}


Result

2017.11.22 00:09:22.368 Test EURUSD,M1: (_R(Array4Save)==Array4Load) = 1 ArraySize(Array4Save) = 1000 ArraySize(Array4Load) = 1000 
 

It runs fine now. How do I use it to exchange data between 2 terminals? 

For example suppose that I am looking for arbitrage opportunities, how do I set it to 2 way data transfer where each client is both client and server?

 
Hannan Nussbaum:

It runs fine now. How do I use it to exchange data between 2 terminals? 

For example suppose that I am looking for arbitrage opportunities, how do I set it to 2 way data transfer where each client is both client and server?

DataSave and DataLoad functions.

 

I'm trying to do the same example between 2 metatrader terminals without success so far.

How the other terminal know what array to look for? By name of array?

It is not working for me so far.

 

if (DataLoad(FileMemory, Array4Load) > 0)    

      Print(TOSTRING((_R(Array4Save) == Array4Load)) +

            TOSTRING(ArraySize(Array4Save)) +

            TOSTRING(ArraySize(Array4Load)));


What is _R in this code and what are you comparing between 2 arrays?

 

What I need is a simple array with ask bid for 2 terminals.

Reason: