- DDE with 2 MT4 terminals at the same time
- Reading Data from Outside the Sandbox
- Logging price data
Is it possible to share data between MT4 terminals on the same VPS?
It is only possible if you are using 3rd Party VPS, but not if using MetaQuotes Virtual Hosting Services.
If using 3rd Party VPS, you can do it via Sockets communications or via a data file in the Common Folder or via Sockets.
Forum on trading, automated trading systems and testing trading strategies
JC, 2017.09.29 10:11
A brief summary of files in the Common folder versus something like socket communication:
Files in the Common folderAdvantages:
- 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 similarAdvantages:
- 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
Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2017.09.28 20:59
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.
Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2017.09.28 23:14
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.
Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Библиотеки: File Mapping без DLL
fxsaber, 2017.04.03 16:07
Thanks to the author for the library!
Wrote the functions to transfer any data. Below the script shows their work on the example of ticks
#include <MemMapLib.mqh> #include <TypeToBytes.mqh> // Selects the specified length memory for data template <typename T> bool GetFileMemory( CMemMapFile* &FileMemory, const int Amount, const string FileName = "Local\\test" ) { FileMemory = new CMemMapFile; return(FileMemory.Open(FileName, sizeof(T) * Amount + sizeof(int) + HEAD_MEM, modeCreate) == 0); } // Writes data to memory template <typename T> void DataSave( CMemMapFile* FileMemory, const T &Data[], const bool FromBegin = true ) { const int Size = ArraySize(Data) * sizeof(T); uchar Bytes[]; _ArrayCopy(Bytes, _R(Size).Bytes); // Copied quantity _ArrayCopy(Bytes, _R(Data).Bytes, sizeof(int)); // Copied data if (FromBegin) FileMemory.Seek(0, SEEK_SET); FileMemory.Write(Bytes, ArraySize(Bytes)); // Have dumped all in memory return; } // Reads data from memory template <typename T> int DataLoad( CMemMapFile* FileMemory, T &Data[], const bool FromBegin = true ) { if (FromBegin) FileMemory.Seek(0, SEEK_SET); uchar Bytes[]; FileMemory.Read(Bytes, sizeof(int)); // Read from memory the amount of data FileMemory.Read(Bytes, _R(Bytes)[0]); // Received the data itself _ArrayCopy(Data, Bytes); // Reset the data in an array return(ArraySize(Data)); } #define AMOUNT 1000 #define TOSTRING(A) #A + " = " + (string)(A) + " " // Example of forwarding ticks void OnStart() { CMemMapFile* FileMemory; if (GetFileMemory<MqlTick>(FileMemory, AMOUNT)) { MqlTick Ticks4Save[]; CopyTicks(_Symbol, Ticks4Save, COPY_TICKS_INFO, 0, AMOUNT); DataSave(FileMemory, Ticks4Save); MqlTick Ticks4Load[]; if (DataLoad(FileMemory, Ticks4Load) > 0) Print(TOSTRING((_R(Ticks4Save) == Ticks4Load)) + TOSTRING(ArraySize(Ticks4Save)) + TOSTRING(ArraySize(Ticks4Load))); FileMemory.Close(); } delete FileMemory; }
Result
(_R(Ticks4Save)==Ticks4Load) = true ArraySize(Ticks4Save) = 1000 ArraySize(Ticks4Load) = 1000
Thanks everyone!
I am using a 3rd Party VPS so all of these methods should work. I will give them a try. I have just been reading about QuickChannel and it does seem fairly straightforward. I'll look into all of them and report back if I run into any issues.
Much appreciated!
It is only possible if you are using 3rd Party VPS, but not if using MetaQuotes Virtual Hosting Services.
If using 3rd Party VPS, you can do it via Sockets communications or via a data file in the Common Folder or via Sockets.
Is creating symlinks/hardlinks possible for MT5?
I am trying to access the same historical data with two different terminals for backtestings my strategy. it works fine with MT4.
I created symlink for the 'Bases' folder to share and use the same historical data with the second terminal, but I can't access the data at the same time. terminal returns "History 'XAUUSD_MB' file opening or reading error [32]".
I tried to change .hcc files permission to Read-only and this time got error "History 'XAUUSD_MB' file opening or reading error [5]".
how can I share historical data for a different MT5 terminal?
Is creating symlinks/hardlinks possible for MT5?
I am trying to access the same historical data with two different terminals for backtestings my strategy. it works fine with MT4.
I created symlink for the 'Bases' folder to share and use the same historical data with the second terminal, but I can't access the data at the same time. terminal returns "History 'XAUUSD_MB' file opening or reading error [32]".
I tried to change .hcc files permission to Read-only and this time got error "History 'XAUUSD_MB' file opening or reading error [5]".
how can I share historical data for a different MT5 terminal?
Why do you need to do that?
Your backtesting and optimizations computational resources are limited to your hardware. What is the sense of running backtests of the same EA from multiple platforms into the same time?
Why do you need to do that?
Your backtesting and optimizations computational resources are limited to your hardware. What is the sense of running backtests of the same EA from multiple platforms into the same time?
Thank you for the quick response.
sorry I forgot to mention it. the purpose is to backtest two different EA, using two different terminals with the same historical data
Thank you for the quick response.
sorry I forgot to mention it. the purpose is to backtest two different EA, using two different terminals with the same historical data
Makes sense, is that a custom symbol with ticks history that take a lot of hard drive space?
Exactly, I have few custom symbols, which occupies large amount of my drive in case I import data to the both terminals.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use