Mt4 Client Api

Posted on  by admin

Move to MetaTrader 5


Modified1 year ago. I have been working on an algorithm ( Not mine, I am just modifying it ) that predicts when to buy and sell on the FOREX market.


  • I need to be able to open and close orders, dynamically update parameters of the orders ( such as stoploss, maximum stop etc.
  • ) and receive real time tick data.
  • I have been researching for well over a week, and have no success.
  • The closest I have gotten is using JavoNet and Mt4 Api.
  • I managed to import the DLL into java and use a MQL4 function, which was AccountBalance(), however this has returned 0.0, which was not the account balance, I messed around with the code and the settings on MT4 client but still no luck.

Q0: Can anyone please point me in the right direction?

I am new to automated FOREX trading but from what I understand there is a broker somewhere with a MT4 server and I connect to that server with my MT4 client on my windows machine.

Q1: If this is the case, do I need to make an API work with the server side instead of my client side?

All these DLL's I have tried so far have been used with the MT4 client software on my machine.

I have also been doing some reading on the FIX-Protocol and ZeroMQ.

Q2: Can these help me achieve my goal in any way (instead of creating some bridges between JAVA and MT4 DLL's)?

  • 11 gold badge33 silver badges1313 bronze badges.
  • 1313 bronze badges.
  • You can try MetaApi cloud service which provides REST API and WebSocket API access to both MetaTrader 4 and MetaTrader 5 accounts.
  • Official REST API documentation:
  • SDKs: (javascript, python and Java SDKs are provided as per April 2021).
  • It supports reading account information, positions, orders, trade history, receiving quotes, and accessing market data.
  • The service also provides copy trading API and API to calculate forex trading metrics on a MetaTrader account

I started to code an expert with MQL5, naturally on MT5 platform, and I must admit that the difficulty of managing the application along with the increase of its complexity is high.

It's not only due to a missing garbage collector, that of course imposes the deletion of the new instances, but also because Java offers a set of powerful data structures and syntax that MQL5 naturally doesn't have.

Last but not least, talking about the community and the third party libraries available, there's a light year of the distance between Java and MQL5.

if I need to find a library for a JSON conversion on the Java side I find dozens of official and stable versions, in the MQL5 community I have found only rubbish that I had to modify myself.

So, after numerous failed tries on coding my expert in MQL5 (not a simple one of course), I decided to adopt a radical approach: coding an application, client-side MQL5, and server-side Java, that provides a Java facade for the MT5 platform.