Hi everyone,
I've been encountering several issues when working with the MetaTrader 5 (MT5) Python API related to account login and server management. I wanted to share my observations and see if anyone has experienced similar problems or found solutions.
Here's a detailed breakdown:
1. Timeout when logging into a new server
When attempting to log into an account on a server that hasn't been added to the MT5 terminal yet, the API call will timeout.
The only way to resolve this is to manually go into the MT5 terminal, navigate to Add New Account, search for the server, and then double-click on the account that is trying to connect. Once this is done, the connection works.
This issue suggests that the API cannot handle server discovery or addition programmatically, which requires manual intervention.
2. Timeout when trying to add an account if no accounts are currently logged in
If the terminal is not logged into any account, attempting to add a new account through the API results in a timeout.
This behavior seems to indicate that the MT5 terminal enters an "idle" or uninitialized state when no accounts are active, preventing API commands from functioning properly.
3. Stuck state when trying to add an account with incorrect credentials
If an account is already logged in and I try to log into another account with incorrect credentials, the terminal/API enters a "stuck" state.
To resolve this, I must manually switch back to a correctly configured account in the MT5 terminal.
After that, I can reconnect successfully.
The terminal/API does not seem to gracefully handle incorrect login attempts and ends up in an undefined or broken state until manually corrected.
Questions
Is there a way to programmatically add servers to the MT5 terminal without manual intervention?
Has anyone else experienced the timeout issue when no accounts are currently logged in? If so, how have you resolved it?
Is there a method to reset or recover the MT5 terminal programmatically when it enters this "stuck" state after incorrect login attempts?
Are there any known workarounds or best practices for handling these scenarios?
Additional Information
I am using the latest version of the MT5 Python API and MT5 terminal (as of December 2024).
All relevant firewall and network configurations have been checked, and this issue does not appear to be related to connectivity.
I would appreciate any insights or solutions from the community.
Thanks in advance for your help!
- MetaTrader 5 account login with incorrect credentials
- Unable to login to the Trader community through the application
- Setting server URL with port instead of server name
Please read prior discussions on this subject and compress your detailed post to one question
Python in algorithmic trading - How to train and deploy a trading algorithm using the same data source for training and deploying a trading algorithms
- 2023.04.13
- MetaQuotes
- www.mql5.com
By comparing returns generated by the same trading signal using different data sources, such as yahoo finance and a broker's data, the speaker highlights the significance of the quality and relevance of the data used
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register