GlobalVariables, MT4 and VPN

To add comments, please log in or register
BR
449
BR  

Hi All,

    Have tried searching with no success.  I am having trouble sharing doubles between 4 EA's running on 4 separate Metatrader4 accounts running on my VPN.  The VPN is running Windows Server 2012R2.  I have used GlobalVariables years ago with no problems... but now they don't seem to cross the distance between EA's.  The commands I'm using are just simple GlobalVariableSet(test1,test1) on the first account, GlobalVariableSet(test2,test2) on the second and GlobalvariableSet(test3,test3) on the third account etc  I have declared test1(and test2, 3 and 4) a double with a value of 1.00.  On each unique account when I search using f3 (GlobalVariable search...) each Metatrader4 running only sees the GlobalVariable set by the EA running on itself... and not seeing any running on the other three accounts.

What gives? How can I share info between these Metatrader4's ??

Thanks for your help !!

Bill

Alain Verleyen
38646
Alain Verleyen  

You can't use Global Variables of the Terminal between several MT4 instances.

BR
449
BR  

Hi Alain, Thanks for your help.... I read this and mis interpreted what it could actually do....It's just between EA's running on the same account on different charts.

https://www.metatrader4.com/en/trading-platform/help/service/global_variables. 

Global Variables - Tools - MetaTrader 4 Help
Global Variables - Tools - MetaTrader 4 Help
  • www.metatrader4.com
Several experts can be launched in the client terminal at the same time. Sometimes, there is a need them to interchange with information. To provide possibility of prompt transfer of moderate amounts of information among experts, as well as organize conflict-free simultaneous working of several experts, there are global variables in the...
Jack Thomas
1626
Jack Thomas  
BR:

This says I should.... what gives?  Or is it just between EA's running on the same account on different charts?

https://www.metatrader4.com/en/trading-platform/help/service/global_variables. 

You can share information between EA on the SAME client terminal using global variables, however global variables cannot send data between different client terminal installations.

That isn't what Global variables are used for.

If you want to exchange data between two or more different client terminal installations, then you will need to build a trade copier of some sort.

There are numerous programmers who can help you with that.

A good trade copier, if you want it done correctly, will run you in the area of $100.00 to $500.00 USD.

https://www.mql5.com/en/job/new

Good luck

- Jack

Fernando Carreiro
4980
Fernando Carreiro  
BR: Have tried searching with no success.  I am having trouble sharing doubles between 4 EA's running on 4 separate Metatrader4 accounts running on my VPN.  The VPN is running Windows Server 2012R2.  I have used GlobalVariables years ago with no problems... but now they don't seem to cross the distance between EA's.  The commands I'm using are just simple GlobalVariableSet(test1,test1) on the first account, GlobalVariableSet(test2,test2) on the second and GlobalvariableSet(test3,test3) on the third account etc  I have declared test1(and test2, 3 and 4) a double with a value of 1.00.  On each unique account when I search using f3 (GlobalVariable search...) each Metatrader4 running only sees the GlobalVariable set by the EA running on itself... and not seeing any running on the other three accounts.

What gives? How can I share info between these Metatrader4's ??

Following a similar (but different) reasoning as presented by @Jack Thomas,  here is a recent Blog post by @JC for a Socket library (with source code) which can be used for communications between EAs.

BR
449
BR  

Hi Jack,

Thanks... I don't want a "Trade Copier"... I just wanted to be able to see data from all my accounts in an empty window populated with info from the EA's.  I wanted account equities, balances, margin levels etc. so I don't have to scroll thru them all to get the big picture of what they are doing. Just trying to streamline my trading.... Wish I knew I couldn't do it before I wrote code into my EA's and Indicators... wasted a lot of hours writing and testing..

BR
449
BR  
Fernando Carreiro:

Following a similar (but different) reasoning as presented by @Jack Thomas,  here is a recent Blog post by @JC for a Socket library (with source code) which can be used for communications between EAs.

Hi Fernando,

Thanks... looks like this is the way I will have to go too. 

Fernando Carreiro
4980
Fernando Carreiro  
BR: Thanks... looks like this is the way I will have to go too. 

Besides the sockets solution, if you want something less elegant but easier to implement, you can also output the data from each EA into a text file which can then be read by other EAs.

Since the installations are on separate directories and are sand-boxed, you can use HardLinks (NTFS Junctions) to create a common directory for all of them in which all EAs will have access to, independently of the Terminal's Installation directory.

Alain Verleyen
38646
Alain Verleyen  
Fernando Carreiro:

Besides the sockets solution, if you want something less elegant but easier to implement, you can also output the data from each EA into a text file which can then be read by other EAs.

Since the installations are on separate directories and are sand-boxed, you can use HardLinks (NTFS Junctions) to create a common directory for all of them in which all EAs will have access to, independently of the Terminal's Installation directory.

or use the Common folder.

Fernando Carreiro
4980
Fernando Carreiro  
Alain Verleyen: or use the Common folder.

True! I forgot about that one!

EDIT: Does it also work in Portable mode?

EDIT2: Just tested it and yes, it does work in Portable Mode and both MT4 and MT5 share the same common folder, so it is a possible cross-platform solution.

%USERPROFILE%\AppData\Roaming\MetaQuotes\Terminal\Common

JC
1646
JC  
BR:

Thanks... looks like this is the way I will have to go too.  

A brief summary of files in the Common folder versus something like socket communication:


Files in the Common folder

Advantages:

  • Relatively simple
  • Uses only native MQL functions; does not require "Allow DLL imports" to be turned on

Disadvantages:

  • Higher message latency
  • Higher processor usage. Receiving EA must not only repeatedly poll the file, but also inspect it for changes
  • Relatively hard to extend from a single repeated status update to a variety of different message types from the clients (e.g. differential notification of a new open trade)
  • Can't scale beyond a single computer


Sockets, or similar

Advantages:

  • Lower message latency
  • Lower processor usage. Receiving EA can sit idle until a new update arrives, rather than repeatedly polling in OnTimer(). No disk I/O.
  • Inherently message-based, and easier to expand from a single repeated status update to a variety of different message types from clients to receiver
  • Can potentially work across multiple computers

Disadvantages:

  • Relatively complex
  • Requires "Allow DLL imports" to be turned on

12
To add comments, please log in or register