ZeroMQ - Distributed Trading Infrastructure

ZeroMQ – How To Interface Python/R with MetaTrader 4

Zero MQ - Distributed Messaging

ZeroMQ – Distributed Messaging

In this post, we present a technique employing ZeroMQ (an Open Source, Asynchronous Messaging Library and Concurrency Framework) for building a basic – but easily extensible – high performance bridge between external (non-MQL) programming languages and MetaTrader 4.


Reasons for writing this post:

  1. Lack of comprehensive, publicly available literature about this topic on the web.
  2. Traders have traditionally relied on Winsock/WinAPI based solutions that often require revision with both Microsoft™ and MetaQuotes™ updates.
  3. Alternatives to ZeroMQ include named pipes, and approaches where filesystem-dependent functionality forms the bridge between MetaTrader and external languages.


Click below to watch the video tutorials:

1) How to Interface Python Trading Strategies with MetaTrader

2) Algorithmic Trading via ZeroMQ: Trade Execution, Reporting & Management

3) Algorithmic Trading via ZeroMQ: Subscribing to Market Data

4) Build Algorithmic Trading Strategies with Python & ZeroMQ: Part 1

5) Build Algorithmic Trading Strategies with Python & ZeroMQ: Part 2

In this blog post, we lay the foundation for a distributed trading system that will:

  1. Consist of one or more trading strategies developed outside MetaTrader 4 (non-MQL),
  2. Use MetaTrader 4 for acquiring market data, trade execution and management,
  3. Support multiple non-MQL strategies interfacing with MetaTrader 4 simultaneously,
  4. Consider each trading strategy as an independent “Client”,
  5. Consider MetaTrader 4 as the “Server”, and medium to market,
  6. Permit both Server and Clients to communicate with each other on-demand.


Infographic: ZeroMQ-Enabled Distributed Trading Infrastructure (with MetaTrader 4)

Infographic: ZeroMQ-Enabled Distributed Trading Infrastructure (with MetaTrader 4)

Why ZeroMQ?

  1. Enables programmers to connect any code to any other code, in a number of ways.
  2. Eliminates a MetaTrader user’s dependency on just MetaTrader-supported technology (features, indicators, language constructs, libraries, etc.)
  3. Traders can develop indicators and strategies in C/C#/C++, Python, R and Java (to name a few), and deploy to market via MetaTrader 4.
  4. Leverage machine learning toolkits in Python and R for complex data analysis and strategy development, while interfacing with MetaTrader 4 for trade execution and management.
  5. ZeroMQ can be used as a high-performance transport layer in sophisticated, distributed trading systems otherwise difficult to implement in MQL.
  6. Different strategy components can be built in different languages if required, and seamlessly talk to each other over TCP, in-process, inter-process or multicast protocols.
  7. Multiple communication patterns and disconnected operation.

ZeroMQ: Supported Programming Languages

Though we focus on MQL interfaced with Python & R in this post, the basic process described here can be implemented easily in other ZeroMQ-supported languages.

A comprehensive list of ZeroMQ language bindings is available here:

Zero MQ Language Bindings

Who else is using ZeroMQ?

AT&T, Cisco, EA, Los Alamos Labs, NASA, Weta Digital, Zynga, Spotify, Samsung Electronics, Microsoft, CERN and Darwinex Labs.

ZeroMQ also powers at least 5 DARWINS on The DARWIN Exchange, where the underlying trading strategies were written in C++, Python and R.

Planning Flow Control

This post is not intended to be a detailed tutorial on ZeroMQ.

However, it is still important to understand a few things about ZeroMQ that make it particularly suited to the task of connecting external programming languages such as Python and R to MetaTrader 4.

  • It supports TCP, inter-process, in-process, PGM and EPGM enabled multicast networking. We will use the TCP transport type for the implementation in this post.
  • ZeroMQ enables servers and clients to connect “to each other” on demand, particularly useful for designing distributed trading infrastructure.
  • In addition to support for asynchronous communication and disconnected operation, ZeroMQ supports several communication patterns that permit higher-level data transfer, freeing programmers to focus more on the transfer logic rather than low-level mechanisms.
  • These patterns include: Request (REQ) / Reply (REP), Publish (PUB) / Subscribe (SUB) and Push (PUSH) / Pull (PULL).


For the implementation in this blog post, we will employ ZeroMQ’s REQ/REP and PUSH/PULL communication patterns. MetaTrader 4 will be our “Server”, and trading strategies will be “Clients”.

Please note that this (MT4=Server, Strategy=Client) is not a MUST – you will need to decide on whatever flow control suits your particular needs best.

For example, you might designate a machine independent of both the trading strategy as well as MetaTrader 4, as your Server, and have Strategies and MT4 both be Clients. There are a number of ways you could achieve the end goal; carefully planning flow control will lead to efficient functionality.


Request (REQ) / Reply (REP) Pattern

The Server (MetaTrader 4 EA) will employ a TCP socket of type REP, to receive requests and send responses. A REP socket MUST always initiate a pair of calls: first, a receive, followed by a send.

The Client (Trading Strategy, e.g. in Python) will employ a TCP socket of type REQ, to send requests and receive responses. A REQ socket MUST always initiate a pair of calls too: first, a send, followed by a receive.

For this implementation, the REQ/REP pattern will enable our Clients to send commands to the MetaTrader 4 Server and receive acknowledgements of the same (e.g. OPEN/MODIFY/CLOSE trades, GET BID/ASK RATES, GET HISTORICAL PRICES, etc.)


Push (PUSH) / Pull (PULL) Pattern

The Server (MetaTrader 4 EA) will also employ a second, PUSH socket, to send additional information to Clients (Trading Strategies). This is a one-way socket, and the server will only be able to send data to this socket, without being able to receive anything back through the same socket.

The Client (Trading Strategy) will also employ a second, PULL socket, to receive additional information from the Server. This too is a one-way socket, and the client will only be able to receive data from this socket, without being able to send anything through the same socket.

The PUSH/PULL pattern enables servers and clients to exchange data with each other on-demand, but in one direction without expecting a response. This could of course be swapped out for another REQ/REP pattern, depending on your application’s flow control requirements.


In summary, for this post’s basic implementation:

  1. The Server will employ two sockets, one REP and one PUSH.
  2. Each Client will employ two sockets, one REQ and one PULL.


Infographic: What this flow control plan looks like in practice.

Infographic: ZeroMQ Process Flow Control


MetaTrader 4 Expert Advisor – Components

As displayed in the infographic above, the MT4 EA will serve as our ZeroMQ-enabled Server, with three main modules:

  1. MESSAGE ROUTER – This allows the EA to receive commands and send acknowledgements back to connecting Clients (trading strategies) through the REP socket. The Router passes all messages on to the Parser. Note: For this example, the Router doesn’t serve much purpose, but it is good practice to have this intermediary where several strategies connect to the Server (MT4) and some manner of pre-parse actions may need to be performed.
  2. MESSAGE PARSER – Messages received by this module are decomposed into actions for the next module (Interpreter & Executor).
  3. INTERPRETER & EXECUTOR – This module literally “interprets” decomposed messages and performs requested actions accordingly. For example, if the Client is requesting market data, the module gathers it from the MetaTrader 4 History DB and sends it on to the Client via the PUSH socket. Alternatively, if the Client is requesting a BUY or SELL trade be opened on e.g. the EUR/USD, it sends the trade to market and a notification of success/failure/ticket-info to the Client via the PUSH socket.

Implementation Requirements

  1. ZeroMQ – MQL4 Bindings -> Download and install the required files as instructed here:
  2. For Python -> “pyzmq” library
  3. For R -> “rzmq” library

Sample Code

To give you a head start, we’ve published a functional MetaTrader 4 Expert Advisor with the full implementation discussed in this blog post.

The MQL sample code provided is quite extensible, and can be used as a template in your efforts.

GitHub Links:

  1. DWX ZeroMQ Connector – Python & MQL


  1. The Python source code demonstrates how communication patterns are implemented.
  2. It’s fairly simple to integrate this code in your existing Python/R trading strategies.


[WEBINAR REPLAY] How to Interface Python/R Trading Strategies with MetaTrader 4

[VIDEO TUTORIAL] Algorithmic Trading via ZeroMQ: Trade Execution, Reporting & Management (Python to MetaTrader)

[VIDEO TUTORIAL] Algorithmic Trading via ZeroMQ: Subscribing to Market Data (Python to MetaTrader)

[VIDEO TUTORIAL] Build Algorithmic Trading Strategies with Python & ZeroMQ: Part 1

[VIDEO TUTORIAL] Build Algorithmic Trading Strategies with Python & ZeroMQ: Part 2

Do you have what it takes? – Join the Darwinex Trader Movement!

Darwinex - The Open Trader Exchange

56 replies
  1. Nicolas
    Nicolas says:


    Your bridge MT4-Python looks pretty interesting and easy to handle, so I look forward to using it!
    Although, there is a bunch of files. Could you explicit which files we need and where to put them please?


    • The Market Bull
      The Market Bull says:

      Hi Nicolas 🙂

      Great to hear you’re finding the implementation useful.

      For installing the ZeroMQ MT4 binding used in this blog/webinar, instructions are available at

      This is a 3rd-party open source library on Github. With any such libraries, it is good and safe practice to ensure you run an Antivirus check and validate checksums prior to using the latest downloaded repo.

      All the best!

      • Nicolas
        Nicolas says:

        Hi Market Bull!
        Thanks, I have managed to install and make it run. Have you done/will you do a webinar on how to link several MT4 servers on one Python client with ZMQ?
        I am trying to do it but not obvious implementation..

        • The Market Bull
          The Market Bull says:

          Excellent question @Nicolas 🙂

          One Python ZeroMQ client can indeed connect to multiple MT4 ZeroMQ server instances.

          For example, one way (of many) to achieve this when using the REQ/REP socket communication pattern, is to initialize multiple sockets of type Zmq.REQ in your ZeroMQ Context, each socket connecting to a different MT4 ZeroMQ Server.

          # Create REQ Socket
          reqSocket1 = context.socket(zmq.REQ)
          reqSocket2 = context.socket(zmq.REQ)


          • Nicolas
            Nicolas says:

            Oh great, it is easier than expected!
            Also, why have you decided to send the get quotes request through a req/rep socket but give the response from the MT4 terminal through a push/pull socket instead?

          • The Market Bull
            The Market Bull says:

            Great question again Nicolas – The use of REQ/REP for critical commands, and PUSH/PULL for non-critical commands, is just one of many ways to divide resources in the same ZMQ Context for our example distributed application. It is completely ok to use just one or more REQ/REP sockets as well. Remember, the end goal is “scalability”. Whatever scheme of socket patterns you choose, must be such that it permits scaling this distributed architecture.

  2. Dong
    Dong says:

    Hi, I saw your webinar recording on How to Interface Python/R Trading Strategies with MetaTrader 4 on YouTube and it was greatly presented. very professional although it was a bit short. so I was wondering if we can use the same zeromq approach for a copy trading system (1 signal provider/many subscribers) or is it a bit overkill for such task? Just want to know your thoughts about it. Thanks in advance for your reply.

    • The Market Bull
      The Market Bull says:

      Hi Dong,

      Great to hear you found the webinar useful!

      Yes indeed – though REP/REQ and PUSH/PULL as described in the webinar would apply to your provider/subscriber application, you may also wish to explore ZeroMQ’s PUB/SUB (Publish/Subscribe) communication pattern for this.

      One technicality to bear in mind that when developing ZeroMQ enabled MT4 servers or clients for such a provider/subscriber model: it makes sense to build both as Expert Advisors instead of Indicators (EA’s run in their own thread in the MT4 terminal, whereas Custom Indicators share the same graphics thread that charts and indicators do). Hope this helps!

    • The Market Bull
      The Market Bull says:

      Great question Khairul!

      ZeroMQ does not automatically implement fault tolerance, but does make the task of developing an application-specific fault tolerance topology much simpler than raw implementations.

      This is particularly useful for the development of distributed trading architecture -> ease of use promotes productivity, freeing up developers to focus on logic, management (orders/risk) and flow.

      Hope this helps!

  3. Robert
    Robert says:

    Hi Market Bull, thanks for your webinar, blog and the provided templates on Github. I’ve been looking for a solution like this since brokers that provide python supported APIs are scarce.

    Since I’m running linux (or OSX) I have to run MetaTrader 4 through an emulator like Wine. I’m wondering if you foresee any problems or alterations to make your set-up work? Or maybe you or somebody else has tried this already? Cheers

    • The Market Bull
      The Market Bull says:

      Hi Robert,

      Great question! Though we haven’t tested this configuration on MT4 via Windows emulators, possible issues that could arise would most likely be related to the correct loading and function of ZeroMQ specific DLLs (the rest of the config does not rely on non-standard Windows DLLs).

      So as far as foreseeable problems are concerned, incorrect loading/functioning of ZeroMQ DLLs would negatively impact communications functionality you develop in your strategy (a big problem if the issue does indeed surface).

      We’ll do some more research on this and possibly write another post at some point, dedicated to cross-platform configuration of ZeroMQ-enabled MetaTrader EA’s.

      Thank you for your interest and feedback!

      • Robert
        Robert says:

        Hi Market Bull, thanks for the reply. Before I read your reply I indeed encountered some dll related issues. The trick was to have the correct MS Visual C++ version installed in the latest version of wine (2.22). As a general tip I can recommend using PlayOnLinux due to version control of Wine per virtual drive. Luckily, after doing some research I’m really close now to have it working. I’m now up to the point that MT4 and python can talk to eachother: extracting prices with the get_rates command provided in the python template. However, unfortunately when I try to buy an instrument, wine and metatrader crash and close down.
        In the end it would be nice to have this system running on a Raspberry Pi, so Linux is the way to go for me now. If it’s too unstable I’ll have to switch to Windows. Thanks again!

        • Simo
          Simo says:

          Hi Robert,

          I encountered the same problem working on OSX. Can you please indicate how did you fix the dlls problem ?

          Thank you

  4. Simo
    Simo says:


    I am using MT4 under MAC-OS, and I think I need something similar to the DLLs in my Library for MAC. Can you please help me on this point ?

    Thank you

  5. Justin
    Justin says:

    I tried with Python 3.x the sample code gave many errors.
    I removed python 3.x and installed 2.x & recompiled the libraries etc.
    The sample code doesn’t produce an error, but immediately locks up,
    to the point all I can do is force close.

    I can manually telnet to localhost 5556 something is answering.
    Looks like an issue on the python/client side.

    Any ideas?

    Env: AWS Workspace, Windows 7.

    • The Market Bull
      The Market Bull says:

      Hi Justin!

      Yes indeed, this sample was written for Python 2.7. We’re due to update this content with Python 3 and MQL5 samples soon, so stay tuned.

      Thank you for giving the debug a great shot! Let’s try and resolve this for you then. We haven’t tested this on an AWS instance, but can try and reproduce the issue this end after a few basic checks.

      Could you kindly confirm if you’re experiencing the same lock-up when running the sample on a local machine (this isn’t producing the same errors for us unfortunately..)? If so, logs would be great to diagnose further.

  6. Ricardo
    Ricardo says:

    Hi Market Bull!

    many thanks for providing this great guide! this is a great step in order to bring retail traders into the age of machine learning!

    question: how to handle continuous streaming of events ?
    lets say MT4 is the server and Python is the client.
    There is a new tick value in MT4. The tick event happens at irregular time intervals,and it is considered a critical event (so that would be a a REP? or a PUSH? in MT4 )

    how would this be handled in R/python? there should be a non-blocking reading of the incoming queue,more or less every millisecond and only when there is a new data point, interpret and parse the new data,so not at regular intervals,and if there is no new data the program should go back to whatever it was doing

    is it possible to provide an example of this code in Python? or R ?

    many thanks!

    • The Market Bull
      The Market Bull says:

      Hi Ricardo,

      Many thanks for highlighting this use-case! Much appreciated.

      We’ll work on an example and share in a future post in this ZeroMQ series.

      Quick feedback in response to your thoughts, (using Python as an example):

      1) You may wish to setup an intermediary Python process that handles tick data exchange, effectively parallelizing communication between MetaTrader (ticks get PUSH-ed) and the trading strategy (ticks get PULL-ed). See here for a great little example:

      2) An intermediary STREAMER process isn’t mandatory, but would most likely result in a cleaner architecture and help diagnose data feed related issues without any potential disrupts within your main strategy.

      Thanks again for the idea – our next post will provide an example of such an implementation!

      • Ricardo
        Ricardo says:

        Hi Market Bull!

        many thanks for you reply!

        I am actually doing something similar to the streamer you propose: in Python I am readying the Pull socket and then parsing the data and sending it to different functions depending on the 1st field of the message

        it would be great to incorporate a more event based approach in the examples! looking forward to that.

        I have been looking into asyncio and zeromq, there is an integration starting with python 3

        (if Python is the client) instead of do a recv PULL data every x seconds or recv the REQ response every x seconds in Python it should all be event based

        suggestion: if you have the time/interest: would be great to have a practical example :the “hello word” of trading is a MA cross over system, maybe this could be done : MT5/4 feeds the data to Python, Python calculates the MA and sends the trade open signal. MT confirms, Python sends the order close

        • The Market Bull
          The Market Bull says:

          Hi Ricardo,

          Great stuff, your custom PULL -> Switch -> func1/2/3 approach is valid indeed.

          Yes, in future posts we’ll be focusing on extending the code more to demonstrate what an intraday MT4/5 -> ZeroMQ session would look like, keeping it event-driven for both clarity and efficiency.

          Re: MA Crossover suggestion -> Sure thing! Great idea 🙂 It’s been put on the TODO list, and when ready, we’ll reference you in the corresponding post as being the contributor of the idea.

          Thank you so much for your continued interest – keep that feedback coming!

          • Ricardo
            Ricardo says:

            many thanks Market Bull!. I am actually the one that is very grateful!: your code is what got me started with the MT/Python integration!, there is very little documentation out there and even less with practical examples applied to trading. I am looking forward to your updates!.

  7. Joaquin
    Joaquin says:

    I am testing this R – metatrader4 interface through zmq following your instructions.
    I have achieved to get both of them comunicate and it works well. But when sending RATES|EURUSD, I have to send the order 2 times… In the first time the answer is “No data PUSHED yet…” (this message appears 2 times) and the second time I ask for the rates, I get them, followed by another “No data PUSHED yet…” in a new line.
    I will of course try to diagnose why this is happening but…

    Is this a normal behaviour?

    • The Market Bull
      The Market Bull says:

      Hi Joaquin,

      Great to hear you’re testing R->MetaTrader communications 🙂

      The scripts provided are templates where emphasis was laid on demonstrating functionality more than providing any single fixed implementation, yes.

      The behaviour you’ve highlighted is normal if the script is run “as is”, given how the calls are currently structured (non-blocking, no polling). Therefore, you’ll need to implement additional code to deal with such queued data.

      Hope that helps!

      • Joaquin
        Joaquin says:

        Thanks for the answer!

        I got it working with the RATES, it was just a silly mistake.

        Now I’m running into something a bit frustrating.
        I am still using the template, but improving and extending it. For instance, to close a position I would send the instruction


        I have coded the mql4 “side” to manage this situation. But … When I send this instruction, MT4 crashes! I have tried to print the string of the incoming “components” of the instruction, and sending




        or smaller strings

        arrives correctly to destination. I think I have a memory problem, maybe zmq is trying to read/write in protected memory zones??
        Any clues?


        BTW.- I also wrote comments in the 3rd article of these zeromq articles. I said that I had it solved, but not all… I only THOUGHT I had it solved, because it worked once with long strings… But after a few more tries it went wrong again

    • The Market Bull
      The Market Bull says:

      Hi David,

      As long as the MQL bindings for ZeroMQ remain available publicly, any tools/content we publish will remain supported.

      Should things change however, e.g. an MQL binding we used is no longer publicly available, we will of course revert with alternative solutions.

      Hope this helps!

  8. Francisco S.
    Francisco S. says:

    Hi, Market bull,
    First of all, thank you for this interesting stuff.
    I am trying to create a quote server to feed a real-time trade table. The table will have several trades at the same time on different currency pairs.
    My question is, do I have to feed this 0MQ EA to each of the assets I need getting quotes or is it possible to ask for quotes of a list of symbols on a single EA.

    • The Market Bull
      The Market Bull says:

      Hi Francisco,

      Thank you for your interest – excellent question!

      Yes, you only need the EA loaded on one asset (chart) in MetaTrader.

      To get data for a list of symbols, you’ll need to make some minor modifications to the code in “SWITCH case 4” (I’d recommend encapsulating such logic in its own function and just calling the method from SWITCH case 4, which is currently written the way it is for sake of easy demonstration.)

      For example, you could write code to accept a delimited string of symbols, and subsequently loop through those symbols return delimited data back to the calling client/server instance.

      Hope this helps!

  9. Francisco S.
    Francisco S. says:

    Hi, thank you for this very interesting code.
    I’m trying to use MT4 to request real-time quotes from different currency pairs. Do I need to use one EA on evey asset I need to get quotes from or can I modify your code to request data from a list of asstes?

  10. Francisco S.
    Francisco S. says:

    Sorry for the duplication of my question. There was a glitch and I thought my first message wasn’t delivered.

  11. Bernard
    Bernard says:

    Hi Market Bull,
    I read this blog and watched the vid, it is an amazing session, thanks a lot. I have encountered a problem while trying to replicate the process and I wonder if you can help me troubleshoot it. I run ZeroMQ_MT4_EA_Template.mq4 in MT4 as the “server” and tried to test your sample strategy in, but this is what Python returned to me.

    Traceback (most recent call last):
    File “”, line 65, in
    File “”, line 31, in zeromq_mt4_ea_client
    remote_send(reqSocket, get_rates)
    File “”, line 47, in remote_send
    File “D:\Python\Python-3.6.5\lib\site-packages\zmq\sugar\”, line 392, in send
    return super(Socket, self).send(data, flags=flags, copy=copy, track=track)
    File “zmq\backend\cython\socket.pyx”, line 729, in zmq.backend.cython.socket.Socket.send
    File “zmq\backend\cython\socket.pyx”, line 773, in zmq.backend.cython.socket.Socket.send
    TypeError: unicode not allowed, use send_string

    I downloaded your code directly from your Github page, I have no idea why it won’t work for me. Please help!

    • The Market Bull
      The Market Bull says:

      Hi Bernard,

      Thank you for your question.

      The code was prepared and tested using an instance running Python 2.7.

      The error itself suggests that your current configuration is requiring that Unicode strings first be converted to ASCII. This can be achieved by using send_string() instead of send().

      Given limited resources, we’re unable to dedicate programming assistance in these posts, a certain level of programming experience being assumed. For further assistance in diagnosing such issues that concern a programming language specific question, it is recommended that you visit where it will very likely have been asked before and answered.

      Hope this helps.

    • Ben A
      Ben A says:

      I know I’m a bit late here but a good solution is to make all the strings you send in python binary strings by putting a b before them, for example b”RATES|GBPUSD” instead of just “RATES|GBPUSD”. This issue is a result of running on python 3 instead of 2.

  12. rainchester
    rainchester says:

    Hi Market Bull, thanks for your amazing article! It is very helpful for me. However, it works when I implemented it, but Python always shows

    [SERVER] Processing: RATES|GBPUSD
    Waiting for PUSH from MetaTrader 4..

    Is that means the MT4 cannot send data correctly to Python? I have searched online but I did not get any answers.
    Could you please give me any advice for that?
    Many thanks!

  13. Mohamed Madane
    Mohamed Madane says:

    I have used ZMQPY with MT4 to make an integration ,i have received Data and send orders successfully,However,i would like to receive Account Information like:MARGIN,FREE MARGIN,PROFIT,EQUITY…
    so could i get a simple code,in them would i get what i want
    think you

  14. amin1softco
    amin1softco says:

    i think python don’t need any third party library for communication with mt4
    python + bottle can become simple web-service and mt4 can request json with WebRequest and simply every think work like charm. but for R maybe 0mq is good solution.

    • LungstaTheProgrammer
      LungstaTheProgrammer says:

      Dude you’re a life saver. I cannot seem to get my python script to connect with the MT4 server, using ZerMQ… I didn’t even know that you can make http requests using MQL4. Thank you for the solution. Darwinex team, thanks for the ZeroMQ solution. Please help me by responding to my email, or send me your email so i can send you my code so you can tell me what the problem is. If its not too much. Thank you again, to you too: amin1softco!!!

  15. George
    George says:

    Hi, great information. Can this be used to create custom indicators on the mt4 terminal? I want to use python and its libraries to analyze the data and then export the value of the data point it calculates to an mt4 indicator. From there I can use the indicator within the mt4 terminal.

    Is this possible?

  16. PaulSPb
    PaulSPb says:

    Hi, people!

    In one of the videos I’ve heard about e-mail, that may provide me help from ZeroMQ developers. Did’t find it. Please, tell me where to look for it.

    Is it possible to use mql4-lib for mql5?


  17. BNS Kumar
    BNS Kumar says:


    Is this possible in MQ5. I am trying to push same code (MQ4) in MQ5 but looks like many syntax changes. Is it possible to provide same in MQ5.


  18. rainchester
    rainchester says:

    Hi! It’s a great work and very convenient for me to develop strategies through Python! Unfortunately, sometimes it works well, sometimes when I try to read data in Python and the metatrader crash and close down. I just wondering is there any suggestions to solve the problem? Many thanks!

  19. Matthew Hanna
    Matthew Hanna says:

    Hi, I’m having a small issue where I believe the server is failing to send messages after an indeterminate amount of time through to zmq subscriptions. I’m looking for someone who is able to provide a little information to assist with debugging the server side. I have joined the Slack channel and posted there a similar request. Thank you

    • Michael Søegaard
      Michael Søegaard says:

      Hi, thank you for an awesome MT4-Python implementation! 😀
      I have been struggeling to get return values from MT4. When my python script open or closes a trade I need a return value of eg. the open/close price. As far as I can tell, it’s the “self._thread_data_output” I need to return. Some times it works, but most of the time it doesn’t. What would be the correct (and stable) way of getting the info returned to a value my python script can access?

  20. Gianni
    Gianni says:

    Hi, I have read your blog and seen your video. Amazing! I have searched for a program like this for several time.

    I have a question. Can I use the program written for MT4 and for Python to implement it in my personal program?

  21. Luca Somigli
    Luca Somigli says:


    This is not only a great program, built extremely well for Darwinex, but serves wonderfully for any other algo-trading activity with MT4, which pretty much means a haul lot of brokers. On top of that, I have never seen better tutorials than these ones for a algo stuff.

    One concept I am trying to work around is to build a gold cross algo-trade strategy. Would you be able to make a video on that? Alternatively, how would you approach the algorithm for that type of strategy (ex. where do I get SMA data and how do I compare it for going long/short)?

  22. Chan
    Chan says:


    I’m trying to download the ZeroMQ Server and connector.

    When trying to download the ZeroMQ at step 5, you did not mention where should i store this file as like the earlier steps which you mentioned to drag the folders to meta trader 4 library folder and etc. So i’m rather confuse now on where should i store this file.

    As for the configuration on the ZeroMQ server, there is no the input tab when i am trying to do the configuration part. Is this related to the above issue? Could you give me a guidance on these 2 issues?

    Pardon me if my questions on the above sound stupid as i am really a raw beginner. Thank you.


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *