Hello please see:
TERMINAL_CONNECTED |
Connection to a trade server |
https://www.mql5.com/en/docs/check/terminalinfointeger
- www.mql5.com
Hello please see:
TERMINAL_CONNECTED |
Connection to a trade server |
https://www.mql5.com/en/docs/check/terminalinfointeger
I think this is another quite unnecessary request unless it is used in OnTimer or in OnInit.
If you get a tick in OnCalculate(), OnTick() you are connected (you get true) if you are not connected you don't get a tick and neither function start to work - so you'll never ever get a false!!
And there is nothing provided by mt4 (and mt5 I guess) to determine how long a 'no-connection' time span has been in order to decide to request missed data and re-calculate you values.
Mt4 and Mt5 are offering TerminalInfoInteger(TERMINAL_PING_LAST). But unfortunately this runs in a separate thread so you can catch a no-connection time span only randomly(!) - which would be different if mt4 and mt5 would offer not only the last ping but the previous ping as well - but as I heard: We have no intention...
<Deleted - Please Only Post in English on This Forum>
Hello! There is a script that works in the background (while true), and when switching accounts in the terminal continues to work ... and I need to restart it! Question: how do I catch logout or login? Or how resource-intensive is the AccountNumber () function to use it in while? Can there be a predefined variable for it by the analogy _Digits, _Point, etc ...?
- Perhaps you should use the Russian forum Русский
- You can't use AccountNumber in a while. If you don't exit all loops, the code will be forcefully terminated after three seconds. You can test IsStopped and exit any loops.
- When switching accounts, the EA will go through a Deinit/Init cycle. You can't even look at the account number in Init because there may be no connection to the server yet. When you get the next tick, the account has been logged in. Only then are you good to go. You can not run anything through the switch or catch the logout/login.
- Any script that was running is gone.
Thanks for all the answers! I found a solution!
int account_number = AccountNumber(); while(!IsStopped()) { if(AccountNumber()!=account_number) { Print("Account was changed... please restart."); break; } //service work... }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
<Deleted - Please Only Post in English on This Forum>
--
Hello! There is a script that works in the background (while true), and when switching accounts in the terminal continues to work ... and I need to restart it!
Question: how do I catch logout or login? Or how resource-intensive is the AccountNumber () function to use it in while? Can there be a predefined variable for it by the analogy _Digits, _Point, etc ...?