Exchanging data between two EAs running in different terminals - page 2

 

Since the EA handles the event on a tick-by-tick basis, I have settled on that direction.

The difference in writing one and reading the other from a tick, in theory on the next tick...

 

An idea occurred to me, how about exchanging data through the registry? Create a key, delete a key, all the API's for that seem to be there. I don't know how slow it is, but it seems that the part that is accessed by applications can always be in RAM.

Has it ever crossed anyone's mind? Only it works for terminals on the same machine.

I will dig in this direction :-).

 
Andres писал(а) >>

An idea occurred to me, how about exchanging data through the registry? Create a key, delete a key, all the API's for that seem to be there. I don't know how slow it is, but it seems that the part that is accessed by applications can always be in RAM.

Has it ever crossed anyone's mind? Only it works for terminals on the same machine.

I will dig in this direction :-).

Please give me a link to API for work with registry.

So far I'm considering the variant based on information exchange via files on disk. Both terminals of course work on the same computer.

I have done some testing, and it seems to me the speed is more than enough to exchange data between terminals in less than 1 second, which I think is enough to manage both accounts (BUY and SELL accounts).

Although, I have been very busy at work lately, so I haven't dealt with this problem for a couple of weeks.

Although I've asked a fellow programmer before, but he warned me against dabbling with the registry to solve the problem. He strongly advised me to use file sharing on the hard disk.

That's where I've stopped for now. As soon as I'll have enough free time, I will try to realize this variant with file.

 

http://yandex.ru/yandsearch?text=CreateFileMapping&stpar2=%2Fh0%2Ftm123%2Fs1&stpar4=%2Fs1

The convenience is that there is a reference to the shared memory in the dll.

This address can be used as a structure address. furthermore, your imagination is the only limit :)

 
solandr >> :

Please give me a link to an API to work with the registry.

Example of reading from registry.

 

I have already written a small library, and my EAs are already changing information through the registry. In fact, they are changed through the RAM, no read-write to disk I do not observe. In MSDN it is written that it is better not to shove data more than a couple hundred Kb into the registry.

Library is configured in such a way, that all keys and parameters are created in temporary registry area and are not written in permanent registry. After rebooting these keys are gone.

One BUT, the library works only with string parameters, not more than 255 characters long (limitation in MQL). But this is quite enough. In general the parameters in the registry can be of different types, not just strings, but for now other types are not needed in my opinion. Right now I have two EAs exchanged through the registry, but there may be more :-). Another good thing is that in Win API it is possible to connect to network registry. If someone needs to exchange information between EAs running on different computers in the same network, they can look in this direction. In my opinion, it is quick, simple and reliable, and without any dlls and files. You put in a string, you get a string.

#include "RegLib.mqh"

int hKey;

int init()
{
   // инициализируем дефайны
   InitRegDefines();

   // создаём тестовый ключ
   hKey = CreateKey( HKEY_CURRENT_USER, "!MT4TestKey" );

   // создаём поля по умолчанию
   SetStringValue( hKey, "Bid", "0.0" );
   SetStringValue( hKey, "Ask", "0.0" );

   return( 0 );
}

int start()
{
   // записываем цены в реестр
   SetStringValue( hKey, "Bid", DoubleToStr( Bid, Digits ) );
   SetStringValue( hKey, "Ask", DoubleToStr( Ask, Digits ) );

   // получаем цены в виде строк из реестра
   string BidStr = GetStringValue( hKey, "Bid" );
   string AskStr = GetStringValue( hKey, "Ask" );

   // выводим цены из реестра
   Print( "Bid = ", BidStr, " ", "Ask = ", AskStr );
}

int deinit()
{
   // закрываем ключ
   CloseKey( hKey );
   
   return( 0 );
}
Files:
reglib.zip  4 kb
 
Andres писал(а) >>

An idea occurred to me, how about exchanging data through the registry? Create a key, delete a key, all the API's for that seem to be there. I don't know how slow it is, but it seems that the part that is accessed by applications can always be in RAM.

Has it ever crossed anyone's mind? Only it works for terminals on the same machine.

I will dig in this direction :-).

You can also try to hammer a nail with a light bulb. It works for some people.

 
Integer >> :

You could also try hammering a nail with a light bulb. Some people can do it.

But it's beautiful, don't you think? You could also try using OS variables.

 
granit77 писал(а) >>

But it's beautiful, don't you agree? You could also try using OS variables.

You could also try setting the system time.

 
:))))))))))))))
Reason: