Discussion of article "MetaTrader 5 and Python integration: receiving and sending data" - page 11

 
Thnks bro. This article is greate. You help me a lot. :*
 

Thank you for this article.

Just wander why we need to keep calling socket=SocketCreate() and SocketClose() in OnTick()?

Seems a bit inefficient to repeatedly doing these.
Does it not keep the socket open/alive? Or rather is it possible keep the socket open/alive?

 
Ernesto Che data to draw fibs and channels. In your example python returns two values, but I have to return data for up to 12 different structures with three coordinate points each.
At first I got stuck with the fact that mt5 did not return a long string describing all structures at once. I made the exchange through several shorter queries. Everything seems to work, but from time to time.
Something tells me that it's about the timeout setting. Could you please suggest a direction for finding a solution?
Thanks in advance

Hi! I was raising a socket too. I have a problem - I write an indicator in python. It takes data from mt5 a lot and as much as you want, but to return data to mt5 is not so easy. On the socket it is possible to transmit only a string up to 100 small strings, but I need more. What solutions are there besides socket? And besides web/internet requests of data exchange between Python->MT5? I don't want to raise MySQL DB for this. We are talking about transferring from python to MT5 about 40 currency pairs with a history of 1000 recalculated readings and further construction of indicator lines in MT5... I want to get away from calculations in MT5 as python does it much faster. So I would like to see all lines of the indicator and not only the last bar transmitted by a string once a second.
Can someone advise me something useful?

TCP/IP Socket - MT5 will receive one string anyway and it will not fit 30 000 data.... Limitations of one string variable even in jason format is up to 100 strings. What is the use of such a Socket ?
It turns out that for big data one way out is Python-->MySQL-->MT5

I also came up with this idea:

Using multiprocessing.shared_memory in Python and WinAPI in MQL5 allows you to read data directly from memory.
 
Alex Renko #:
other than web/internet requesters for data exchange between Python->MT5? I don't want to bring up MySQL DB.

"bring up SQLite" - MT5 has it built in, python obviously has it too...

You can use the socket to report what you need promptly (signals, alerts, etc.), and put big data into SQLite. That is, in python you put everything you need into the database and blow the whistle on the "data update" socket. And in MQL you can reread the database on the whistle.

The database itself can be stored on a frame disc

 
Maxim Kuznetsov #:

"bring up SQLite" - MT5 has it built in, python obviously has it as well.

You use the socket to report what you need promptly (signals, alerts, etc.), and put big data into SQLite. That is, in python you put everything you need into the database and blow the whistle on the "data update" socket. And in MQL you can reread the database on the whistle

The database itself can be stored on a frame disc

I see your point, thanks for the answer... I thought so
MetaTrader 5 uses its own programming language MQL5, which runs in an isolated process. This does not allow direct interaction with the shared memory of the operating system, as other applications that use low-level APIs can do.

Shell within a shell.... It's been 20 years since they can't make a native version for mac...

 
Alex Renko #:

I see your point, thanks for the reply.... well I thought so
MetaTrader 5 uses its own programming language MQL5, which runs in an isolated process. This does not allow direct interaction with the shared memory of the operating system, as other applications that use low-level APIs can do.

Shell within a shell.... It's been 20 years since they can't make a native version for mac...

nobody forbids to use DLL - and there you can do what you want.

You can search memory directly (probably no faster :-) ).

Or efficient intermediate solutions, a la in-memory key-value db.

Only in most cases, the brakes and bottle-neck are on Python's side

 
for me not  work example anyone  know  why ? i sett in option 127.0.0.1:9090   i run python socketserver.py e  run EA socketclientEA.ex5 ( after  fix  char   to uchar )run it ,  but retrun me this error 
2025.10.09 10:41:44.665 socketclientEA (#GDAXIm,H1)     Connection localhost:9090 error 4014