TheSnowGuru / PyTrader-python-mt4-mt5-trading-api-connector-drag-n-drop

Open Source Trading Strategies & End-to-End solution connecting Metatrader4 & Metatrader5 💹 with Python with a simple drag and drop EA. Fully tested bug free & efficient solution for live & paper trading⭐ Full Documentation ready. Lightweight, efficient and stable implementation 🔥
https://discord.gg/wRMUNP8ERa
653 stars 11 forks source link

can't connect to the mt5 server #21

Closed hundan2020 closed 2 years ago

hundan2020 commented 2 years ago

my question

I'm trying to test the demo, but someting got wrong. I've already open the dll load, and move the Pytrader_MT5_EA_V2.08.ex5 to script folder, set the params, and click the start, snapshot here

image

image

all seems fine, but when I'm trying to run the python client, the port is 1110 and server ip is 127.0.0.1, I found that the server seems like doesn't response, but the 1110 port is real listening image

as my debug, I found the problem is self.send_command(self.command) the code doesn't got any real response, then the python script just stuck here, how to solve it?

image

image

also following is the test script Python_script_example_PyTrader.txt

my env:

Python 3.7.7

MT5

image image

thanks for response

hundan2020 commented 2 years ago

more details, the log is here , no error output (changed server and client port to 55500 for test this time)

N   0   16:11:29.960    Startup MetaTester 5 x64 build 3121 (03 Dec 2021)
PN  0   16:11:30.015    Server  MetaTester 5 started on 127.0.0.1:3000
MG  0   16:11:30.019    Startup initialization finished
QD  0   16:11:30.190    127.0.0.1   login (build 3050)
JS  0   16:11:30.419    Network 4372 bytes of account info loaded
LD  0   16:11:30.419    Network 1470 bytes of tester parameters loaded
CS  0   16:11:30.419    Network 1212 bytes of input parameters loaded
GF  0   16:11:30.421    Network 24532 bytes of symbols list loaded (1630 symbols)
PS  0   16:11:30.421    Tester  expert file added: Experts\MyEA\Pytrader_MT5_EA_V2.08.ex5. 184626 bytes loaded
HQ  0   16:11:30.466    Tester  4003 Mb available, 49 blocks set for ticks generating
GH  0   16:11:30.466    Tester  initial deposit 10000.00 USD, leverage 1:500
NQ  0   16:11:30.468    Tester  successfully initialized
IG  0   16:11:30.468    Network 202 Kb of total initialization data received
KR  0   16:11:30.468    Tester  Intel Core i7-9750H  @ 2.60GHz, 16240 MB
CH  0   16:11:30.499    Symbols XAUUSD: symbol to be synchronized
FO  0   16:11:30.500    Symbols XAUUSD: symbol synchronized, 3800 bytes of symbol info received
FR  0   16:11:30.500    History XAUUSD: history synchronization started
CJ  0   16:11:30.501    History XAUUSD: load 27 bytes of history data to synchronize in 0:00:00.000
FM  0   16:11:30.501    History XAUUSD: history synchronized from 2020.01.02 to 2022.01.14
MN  0   16:11:30.575    History XAUUSD,M15: history cache allocated for 49665 bars and contains 23668 bars from 2020.01.02 06:00 to 2020.12.31 20:45
MM  0   16:11:30.575    History XAUUSD,M15: history begins from 2020.01.02 06:00
DD  0   16:11:30.576    Tester  XAUUSD,M15 (ForexTimeFXTM-Demo01): every tick generating
MP  0   16:11:30.576    Tester  testing with execution delay 10 milliseconds
ED  0   16:11:30.576    Tester  XAUUSD,M15: testing of Experts\MyEA\Pytrader_MT5_EA_V2.08.ex5 from 2021.01.01 00:00 to 2022.01.15 00:00 started with inputs:
QS  0   16:11:30.576    Tester    ServerPort=55500
LR  0   16:11:30.576    Tester    location=Market\Pytrader MT5
HF  0   16:11:30.610    Tester  program file added: \Indicators\Market\Pytrader MT5.ex5. 13593 bytes loaded
FE  0   16:11:30.628    Pytrader_MT5_EA_V2.08 (XAUUSD,M15)  2021.01.01 00:00:00   Alert: EA working in demo.
QI  0   16:11:30.628    Pytrader_MT5_EA_V2.08 (XAUUSD,M15)  2021.01.01 00:00:00   Server socket created
Branly76 commented 2 years ago

Hi,

Remark the EA …V2.08.ex5 must be located in the expert folder.

BR

Verzonden vanuit Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 voor Windows

Van: Hun @.> Verzonden: zaterdag 15 januari 2022 21:58 Aan: @.> CC: @.***> Onderwerp: [TheSnowGuru/PyTrader-python-mt4-mt5-trading-api-connector-drag-n-drop] can't connect to the mt5 server (Issue #21)

my question

I'm trying to test the demo, but someting got wrong. I've already open the dll load, and move the Pytrader_MT5_EA_V2.08.ex5 to script folder, set the params, and click the start, snapshot here

[image]https://user-images.githubusercontent.com/9510938/149636873-b8d23b90-1c0c-418f-bca3-75bd391e05e6.png

[image]https://user-images.githubusercontent.com/9510938/149636869-410926e4-28ef-4b4f-ad82-edb1270872c5.png

all seems fine, but when I'm trying to run the python client, the port is 1110 and server ip is 127.0.0.1, I found that the server seems like doesn't response, but the 1110 port is real listening [image]https://user-images.githubusercontent.com/9510938/149637125-5f0fcc00-a96a-4fcd-9f6a-dc21e0725fce.png

as my debug, I found the problem is self.send_command(self.command) the code doesn't got any real response, then the python script just stuck here, how to solve it?

[image]https://user-images.githubusercontent.com/9510938/149637190-2768b032-bdd2-4e81-b018-51c330aff1d4.png

[image]https://user-images.githubusercontent.com/9510938/149637183-4007c350-f83f-4660-9ffd-18b518237786.png

also following is the test script Python_script_example_PyTrader.txthttps://github.com/TheSnowGuru/PyTrader-python-mt4-mt5-trading-api-connector-drag-n-drop/files/7875858/Python_script_example_PyTrader.txt

my env:

Python 3.7.7

MT5

[image]https://user-images.githubusercontent.com/9510938/149637408-b1f686f2-6dca-40e7-817c-9e011ab2d8cb.png [image]https://user-images.githubusercontent.com/9510938/149637414-c29bd83e-4000-488b-b939-394098c905ad.png

— Reply to this email directly, view it on GitHubhttps://github.com/TheSnowGuru/PyTrader-python-mt4-mt5-trading-api-connector-drag-n-drop/issues/21, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APKJKZEBNNJQ4SJGY6EXRWTUWHNVNANCNFSM5MBNDF5A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Branly76 commented 2 years ago

More general. EA in expert folder. Pytrader_API in your python project.

I see in a picture, that you put the EA in backtester of MT5 ? Is this right ?

If yes, you can not use this EA in MT5 backtester. The reason is MT backtester is already using socket port communication, Pytrader_API does also. This combination does not work. Explain me what you want to do/application.

BR

Verzonden vanuit Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 voor Windows

Van: Hun @.> Verzonden: zondag 16 januari 2022 09:14 Aan: @.> CC: @.***> Onderwerp: Re: [TheSnowGuru/PyTrader-python-mt4-mt5-trading-api-connector-drag-n-drop] can't connect to the mt5 server (Issue #21)

more details, the log is here , no error output (changed server and client port to 55500 for test this time)

N 0 16:11:29.960 Startup MetaTester 5 x64 build 3121 (03 Dec 2021)

PN 0 16:11:30.015 Server MetaTester 5 started on 127.0.0.1:3000

MG 0 16:11:30.019 Startup initialization finished

QD 0 16:11:30.190 127.0.0.1 login (build 3050)

JS 0 16:11:30.419 Network 4372 bytes of account info loaded

LD 0 16:11:30.419 Network 1470 bytes of tester parameters loaded

CS 0 16:11:30.419 Network 1212 bytes of input parameters loaded

GF 0 16:11:30.421 Network 24532 bytes of symbols list loaded (1630 symbols)

PS 0 16:11:30.421 Tester expert file added: Experts\MyEA\Pytrader_MT5_EA_V2.08.ex5. 184626 bytes loaded

HQ 0 16:11:30.466 Tester 4003 Mb available, 49 blocks set for ticks generating

GH 0 16:11:30.466 Tester initial deposit 10000.00 USD, leverage 1:500

NQ 0 16:11:30.468 Tester successfully initialized

IG 0 16:11:30.468 Network 202 Kb of total initialization data received

KR 0 16:11:30.468 Tester Intel Core i7-9750H @ 2.60GHz, 16240 MB

CH 0 16:11:30.499 Symbols XAUUSD: symbol to be synchronized

FO 0 16:11:30.500 Symbols XAUUSD: symbol synchronized, 3800 bytes of symbol info received

FR 0 16:11:30.500 History XAUUSD: history synchronization started

CJ 0 16:11:30.501 History XAUUSD: load 27 bytes of history data to synchronize in 0:00:00.000

FM 0 16:11:30.501 History XAUUSD: history synchronized from 2020.01.02 to 2022.01.14

MN 0 16:11:30.575 History XAUUSD,M15: history cache allocated for 49665 bars and contains 23668 bars from 2020.01.02 06:00 to 2020.12.31 20:45

MM 0 16:11:30.575 History XAUUSD,M15: history begins from 2020.01.02 06:00

DD 0 16:11:30.576 Tester XAUUSD,M15 (ForexTimeFXTM-Demo01): every tick generating

MP 0 16:11:30.576 Tester testing with execution delay 10 milliseconds

ED 0 16:11:30.576 Tester XAUUSD,M15: testing of Experts\MyEA\Pytrader_MT5_EA_V2.08.ex5 from 2021.01.01 00:00 to 2022.01.15 00:00 started with inputs:

QS 0 16:11:30.576 Tester ServerPort=55500

LR 0 16:11:30.576 Tester location=Market\Pytrader MT5

HF 0 16:11:30.610 Tester program file added: \Indicators\Market\Pytrader MT5.ex5. 13593 bytes loaded

FE 0 16:11:30.628 Pytrader_MT5_EA_V2.08 (XAUUSD,M15) 2021.01.01 00:00:00 Alert: EA working in demo.

QI 0 16:11:30.628 Pytrader_MT5_EA_V2.08 (XAUUSD,M15) 2021.01.01 00:00:00 Server socket created

— Reply to this email directly, view it on GitHubhttps://github.com/TheSnowGuru/PyTrader-python-mt4-mt5-trading-api-connector-drag-n-drop/issues/21#issuecomment-1013830990, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APKJKZEGP5V63JRAI3LBXZ3UWJ46RANCNFSM5MBNDF5A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.***>

hundan2020 commented 2 years ago

thanks for answering

yes, I found the correct usage now, just attach to the chart, it works well now.

but I do wanna do a backtest with mt5 backtest function by python, so seems like our project can't support temporery or will never be able to imple? is that theoretically possible by tech?

Branly76 commented 2 years ago

MT5 does not allow EA's which use Socket ports. I tried myself. This is technical not possible according MT5 blogs.

Do you need Tick data for your backtesting ?

BR

hundan2020 commented 2 years ago

Tick data is better, but I don't understand... your reply sounds like there is some alternative solution?

the idea of using mt5 framework for backtest, is just for a intuitive effect, my alternative solution is using https://github.com/kernc/backtesting.py , is there better advice or some idea?

Branly76 commented 2 years ago

Tick data is probably the best, but you have many records. For example eurusd will be about 150k records for 24 hours, btcusd go up to 350 k records in 24 hours. Maybe i have something, but needs some work to for it.