1

Screenshot ofDirectory and Errors here

I'm trying to built 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.

1 Answers1

0

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.

Sean Champ
  • 191
  • 2
  • 14