Migrating MT5 to MT4 in Python

 
Hi everyone. I use MT5 with python for AlgoTrading.

I can do these in my python script:
  • Get historical data
  • Send order
  • Close position

via https://www.mql5.com/en/docs/integration/python_metatrader5 .

But, in my country, most of the Forex companies still work with MetaTrader4. 

I did some research but couldn't find any python module for MetaTrader4 or any other viable way to connect my python script to MT4


My question is,

How do you connect your python scripts to MetaTrader4 and get historical data, send orders, close positions?

And the second question, What does your python code do in case of internet connection lost?


Thanks

 
yusuftaha11: Hi everyone. I use MT5 with python for AlgoTrading. I did some research but couldn't find any python module for MetaTrader4 or any other viable way to connect my python script to MT4.

My question is, How do you connect your python scripts to MetaTrader4 and get historical data, send orders, close positions? And the second question, What does your python code do in case of internet connection lost?

MT4 does not have a Python integration like MT5. The only way to directly integrate MT4 with other system is via DLL calls (usually coded in C++), but MT4 will always act as the "server" or "master" and the DLLs will act as the "client" or "slave". DLL's are after-all just dynamic libraries!

 
Fernando Carreiro #:

MT4 does not have a Python integration like MT5. The only way to directly integrate MT4 with other system is via DLL calls (usually coded in C++), but MT4 will always act as the "server" or "master" and the DLLs will act as the "client" or "slave". DLL's are after-all just dynamic libraries!

the only way i can suggest using  python and mt4 is through files as a link between python and mt4 expert advisors, with python you process and put results in a file and mt4 expert read the file and act accordingly
 
the only way i can suggest using  python and mt4 is through files as a link between python and mt4 expert advisors, with python you process and put results in a file and mt4 expert read the file and act accordingly

it may be somehow slow but wiill do the job
Reason: