aminch8 / MT5-Java

A Library to simplify using Meta Trader 5 through Java
5 stars 1 forks source link

PORT BY DEFAULT? #1

Closed ghost closed 1 year ago

ghost commented 1 year ago

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

thanks in advance david

aminch8 commented 1 year ago

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

ghost commented 1 year ago

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 ..?

aminch8 commented 1 year ago

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).

ghost commented 1 year ago

Hello Ta4j is very buggy unfortunately but it’s a good project I find all indicator code in mt5 I will do it In Java . Is the price value near real-time in mt5 ??

Kind regards

David

On Tue 20 Jun 2023 at 16:31, Amin Chokan @.***> wrote:

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 https://github.com/ta4j/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).

— Reply to this email directly, view it on GitHub https://github.com/aminch8/MT5-Java/issues/1#issuecomment-1598908499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF33OJ7GNV6JUDSQLG7ES7DXMGX3TANCNFSM6AAAAAAZNEWF5M . You are receiving this because you modified the open/close state.Message ID: @.***>

aminch8 commented 1 year ago

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.

ghost commented 1 year ago

Allow me to thank you for all your advice ! Yes realtime is expansive , it give a large advance to big pocket people...

On Tue, Jun 20, 2023 at 6:27 PM Amin Chokan @.***> wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/aminch8/MT5-Java/issues/1#issuecomment-1599122512, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF33OJZVEDKRSTRCCKA2OBTXMHFP3ANCNFSM6AAAAAAZNEWF5M . You are receiving this because you modified the open/close state.Message ID: @.***>