Cannot get MQL4 to connect with python via ZMQ

Cannot get MQL4 to connect with python via ZMQ

Manage alerts

Loading saved threads...

Rylie Harrison · External communityPost link
External question — Stack Overflow Stack Exchange Author: Rylie Harrison Original post: https://stackoverflow.com/questions/76650506 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I'm trying to build an algorithmic trading bot. First step is to establish a connection between Python and MQL4 EA. I have the dir set up correctly. As shown below and my scripts are as follows. My Python script is listening for a reponse although I am never able to compile the script in MQL4 - it gives the following errors. Screenshot attached. Any advice would be greatly appreciated. Notes - using fusion markets version of MT4 Python import zmq print("Current libzmq version is ", zmq.zmq_version()) print("Current pyzmq version is ", zmq.pyzmq_version()) context = zmq.Context() # Create a REP socket instead of PAIR socket = context.socket(zmq.REP) socket.bind("tcp://*:5555") # Wait for a request message = socket.recv_string() print("Received request: %s" % message) # Send a reply socket.send_string("Hello from Python!")` MQL4 // Include the ZMQ library #include <Zmq/Zmq.mqh> // Create a ZMQ context ZmqContext context; // Create a ZMQ socket ZmqSocket socket(context, ZMQ_REQ); // ZMQ_REQ means it's a Request socket // The entry point of the script int start() { // Connect to a ZMQ server socket.connect("tcp://localhost:5555"); // replace "localhost:5555" with your ZMQ server address // Send a message socket.send("Hello from MQL4!"); // Receive a message char buffer[256]; socket.recv(buffer); // Print the received message Print("Received: ", buffer); return 0; } I tried changing the code, ensuring python script was running. Redownloading zmq files and moving to dir etc.
Quote
Report
Sean Champ · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Sean Champ Original post: https://stackoverflow.com/a/76833391 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. It looks like there may have been a preprocessor error of some kind? I've seen similar messages when compiling MQL source code that the preprocessor wasn't able to process. This could be due to syntax errors in the source code, or something otherwise that the preprocessor was not able to parse. I'd recommend taking another look at the include files. The preprocessor for the MQL compiler might be failing somewhere in one of those files. If those include files are each annotated with #property library and would each be edited then compiled individually in Metaeditor, maybe the compiler will provide more information when compiling each individual file.
Quote
Report

Post Reply

Checking account access…
Cannot get MQL4 to connect with python via ZMQ | Forex.com.bd