Connection of MATLAB and MetaTrader 4 or 5 via ZeroMQ

2020.06.12 Integration


After some days of research, I've come to the conclusion that the probably best and fastest communication protocol between MT4/5 and MATLAB, is by ZeroMQ. After testing its development on Python by Darwinex (, it seems to be even more reliable and functional that MQL5's official py wrapper itself. This is because of its asynchronous PUB/SUB messaging pipeline: the ability for MQL5 (server) to send and force market tick appending on a DataFrame (for example) without Python (client) explicitly requesting for it. On the other hand, it also has a Push/Pull channel by which Python (client) can send commands (buy/stop/limit, sell/stop/limit, request market/trade/account data, modify/close order, etc) to MQL5 (server) and expect the latter to respond if necessary.

I've got my strategies and mathematical tools installed in MATLAB. My experience in MATLAB is solid but doesn't go beyond some toolboxes, GUIs and application-specific functions. I do not have knowledge about C++ compiling, Java class usage and sockets. So...

I need a function/class library with pretty much the same capabilities and syntax of the aforementioned Pythonic one created by Darwinex. The more similar, the better. It should be preferably be able to synchronize with the MQL expert advisor created by Darwinex too. It should have a "Connector" class which links to the MetaTrader expert advisor. The "Connector" should have the following methods:

  • "Subscribe to data": Ask for MQL EA to start sending (PUBlishing) tick data from a certain quote, so that it gets automatically logged onto a timetable or array. "Unsuscribe to data" too.
  • "Get market data": Request MQL EA for a certain quote's market history data between a start date and an end date, in a defined timeframe.
  • "Trade": Send trading orders, buy/sell, market/stop/limit, being able to specify lot size, magic number, slippage, stop loss, take profit (and stop/limit price when applicable).
  • "Modify": Modify order's stop loss, take profit (and stop/limit price when applicable).
  • "Close": Close positions by ticket number, either partially or totally. Also cancel pending orders. 
  • "Get account data": Request summary of account details... At least: balance, equity, margin, margin level, leverage.
  • "Get open positions" and "Get pending orders".
  • "Disconnect": Total shutdown of communication lines when necessary.
  • Data flow speed is essential. 

The most that can be done from Matlab without depending from stuff in other languages, the best. I know this work has been done in the past with imports from Java classes ( or from MEX compilers ( but I just can't make them work, and I don't think that they could have the simplicity of syntax that I need.

Project information

50 - 100 USD
For the developer
45 - 90 USD
to 7 day(s)


Placed orders1
Arbitrage count0