How to transfer live data between Python and MQL4?

How to transfer live data between Python and MQL4?

Manage alerts

Loading saved threads...

Kemal Bayram · External communityPost link
External question — Stack Overflow Stack Exchange Author: Kemal Bayram Original post: https://stackoverflow.com/questions/64429878 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Python code: import zmq import sys port ="5555" print("Connecting to hello world server…") context = zmq.Context() socket = context.socket(zmq.REQ) # Socket to talk to server socket.connect("tcp://localhost:%s"%port) while(1): # Do requests, try: # waiting each time for a response message = socket.recv() print(message) except: pass MQL4 code: #include <Zmq/Zmq.mqh> Context context("helloworld"); Socket socket(context,ZMQ_REP); socket.bind("tcp://*:5555"); ZmqMsg request; ZmqMsg reply("Trade was executed"); socket.send(reply); Print("Feedback: Trade was executed"); an infinite loop occurs when I want to send data from MQL4 to the Python programming language as above Python cannot receive message data through the port
Quote
Report
user3666197 · External communityPost link
External answer — Stack Overflow Stack Exchange Author: user3666197 Original post: https://stackoverflow.com/a/64435171 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Q : "How to transfer live data between python and mql4?" Starting to use the REQ/REP Scalable Formal Communication Archetype is rather demanding. Your mock-up code ignores the mechanics of this archetype, having not received a REQ -side message ( which your code does not perform ), the REP -side will never get into a state ( REQ/REP is a dFSA - a distributed Finite State Automaton ), where a .send() -method can execute ( the native API would report an error state, that shows cases, where a dFSA state-rules are violated ). Use PUSH/PULL instead and your demo-code will not fall into problems. MQL4-side will PUSH , python-side will PULL . I use this since ZeroMQ v2.11 was ported as a DLL for use with MQL4, and all my distributed-computing trading projects are working as charm.
Quote
Report

Post Reply

Checking account access…