Possibility to join MQL4 and Python 3.X versions

 

Hello,

Is it possible to join Python 3.X with Metatrader? I found on internet that links are done only for 2.6-2.7 versions.  And of course none of them are working for Python 3.5 version.

 
do not know about the versions (I am not a coder) but you can check in search here (there are two articles related).
 

Of course it's possible.

 
Sergey Golubev:
do not know about the versions (I am not a coder) but you can check in search here (there are two articles related).

Hello,

Thank you for a link. Looked through it but it talks only about MQL5, not MQL4

 
Marco vd Heijden:

Of course it's possible.


Marco, could you give a  hint? I want to grab data from MQL4 send to Python script for processing and then if result is OK to execute trade in Metatrader. Checked dlls but found only ones created for Python2.7 and nothing for 3.5 version.  Also checked web service, that guys  have created here:

https://github.com/OpenTrading/OpenTrader  but it also only for 2.7 version...

 

Yes the hint is try until you succeed.

At least that's what i always do.

For example you can write to file and read it by python.

There can be other options too it depends on the application requirements.

 
Marco vd Heijden:

Yes the hint is try until you succeed.

At least that's what i always do.

For example you can write to file and read it by python.

There can be other options too it depends on the application requirements.


Well this one won't work:) it is easy to write into file with one software and read it with another. However, i need that these taken data series could be processed and order has to be placed. So basically if i write to file and next second i read it and answwer i write back to file and read back with MQL for order open, it will be already passed at least 5-10 seconds from candle open. And this my strategy is for M5, so time matters and saving/reading to file is not an option.

 

I do not see any problem with it.(have been using it for a long-long time)

It does not take 5-10 seconds, and even if it did it would not form a problem for me, 5 or 10 seconds is nothing on a Daily candle.

Maybe you are trying to connect feeds and trade the tiny differences, that would be the only area i can think of where it would be critical.

For that you would have to set up some pipes. https://www.mql5.com/en/search#!keyword=pipes

If it does not suit your needs you will have to dive in somewhat deeper and build customized (complexer) bridges.

 
Marco vd Heijden:

I do not see any problem with it.(have been using it for a long-long time)

It does not take 5-10 seconds, and even if it did it would not form a problem for me, 5 or 10 seconds is nothing on a Daily candle.

Maybe you are trying to connect feeds and trade the tiny differences, that would be the only area i can think of where it would be critical.

For that you would have to set up some pipes. https://www.mql5.com/en/search#!keyword=pipes

If it does not suit your needs you will have to dive in somewhat deeper and build customized (complexer) bridges.


As i told my EA is trading on M5, not D1. So speed is pretty much important. Thank you for a link to pipes. I will look at these :)

 

You should be able to use every standard Windows interprocess communications protocol. These are options I can remember now:

  1. use simple files
  2. use named pipes (there is a sample in the Scripts/Examples/Pipes folder, also check Include/Files/FilePipe.mqh)
  3. create a C++ dll for MQL and interface that to Python code (you can find MQL dll sample in the Scripts/Examples/DLL folder)
  4. use Iron Python and create .net assembly and then access that from MQL through dll (this is a variation of 3.)
  5. tcp/ip communication using wininet.dll 
  6. memory mapped files 
For each of these, you should be able to find more code samples and articles on this site and the internet.

 
Drazen Penic:

You should be able to use every standard Windows interprocess communications protocol. These are options I can remember now:

  1. use simple files
  2. use named pipes (there is a sample in the Scripts/Examples/Pipes folder, also check Include/Files/FilePipe.mqh)
  3. create a C++ dll for MQL and interface that to Python code (you can find MQL dll sample in the Scripts/Examples/DLL folder)
  4. use Iron Python and create .net assembly and then access that from MQL through dll (this is a variation of 3.)
  5. tcp/ip communication using wininet.dll 
  6. memory mapped files 
For each of these, you should be able to find more code samples and articles on this site and the internet.


Lovely,

Thank you!

Reason: