aminch8/MT5-Java

PORT BY DEFAULT?

Closed this issue · 6 comments

Hello ,
what is the the value systemPort, int dataPort use by mt5 ??

thanks in advance
david

Hi, these values are set in the expert advisor.
I'm very sorry that the repositories are not well documented.

First of all you need to add Expert Advisor for your MetaTrader 5. To do that follow the instructions in this repository.
https://github.com/aminch8/MT5-ZeroMQ

Inside the repository above, you will see some files. you need to paste them into your meta trader directory.
There is readme file in 'zmqfiles' folders as well.
This repository needs some serious cleanups which i haven't had the time to do it yet.

After setting up the Expert Advisor, u need to drag and drop it on a chart to enable it, after this, you can interact with your meta trader through Java.

The concept is that, the EA uses ZeroMQ socket to interact with other programs and vice versa. so we can get data from MetaTrader or send some messages that will do something for us, like executing a market order or telling it to send us current positions. I haven't written the zeromq EA myself.

You may be wondering about the latency of exchanging messages through sockets, i did a little test, the average response time is about 5-7ms which is the average latency of Meta Trader 5 itself. You can't beat that.

The ports can be changed in the expert advisor itself, but the default values are:
SystemPort = 2201
DataPort = 2202
LivePort = 2203

Im already using this with my own algorithmic trading right now, live testing it actually. Im using spring containers to do so.

like this:
@Bean public MT5Client getMT5Client(){ return new MT5Client.MT5ClientFactory(2201,2202).build(); }

or this:
@Bean public MT5LiveData getMT5LiveData(){ return new MT5LiveData.MT5LiveDataFactory(2203,getMT5Client()).build(); }

I hope this was helpful.
Sorry for messed up documentations

Thank you very much , i build my own engine but indicators are buggy , i am wondering if i could use the mt5 indicators for a specific symbol and receive it with more precision ??
Your project is cool and well coded, i dont know if you want to continue the dev ..?

I will 100% continue the development, i just have some other priorities right now. I'm looking forward to finishing this project and publishing at maven central.

In my opinion, if u want to calculate indicators, use TA4J, its an incredible well written and has basic indicators. You can extend a class to write your own indicator/calculation as well. ( i use it cause it has caching mechanism which makes calculation extremely fast ).

I get tick/candle data from MetaTrader 5, calculate the indicators inside java code.

If you want to calculate indicator data and send it from MetaTrader5, you need to edit the MQL file of Expert Advisor which is named jsonApi.mq5. its about thousand lines, not very difficult to edit. If you know basic MQL, you can easily add this feature to retrieve indicator data. (You create the indicator inside EA and send the values to java through ZeroMQ Socket for each tick or candle close).

I have never encountered an issue with it yet.
The price really depends on the brokerage but the most realtime price would be to get from CME which is not free.

The delay from ZeroMQ is near zero, you can ignore it in my opinion.

I have read some tests ran on ZeroMQ, seems pretty fast.

I can't say this is the fastest way but i can say i haven't found a better way to get realtime quotes faster without purchasing the price feed from CME.