MT5TerminalInfo

Get status and parameters of the connected MetaTrader 5 terminal.

MT5TerminalInfo()

Return Value

Returns connection status, trade server name and trading account number.

Note

The value is returned as a tuple of three values:

Type

Description

Sample value

integer

Connection status to the trade server: 0 – no connection, 1 – the terminal has connected, but the trading environment has not yet been synchronized, 2 – the terminal has connected to the trade server

2

string

Trade server name

'MetaQuotes-Demo'

string

Trading account (login) index

'15185779'

Example:

from datetime import datetime
from MetaTrader5 import *
 
# connect to MetaTrader 5
MT5Initialize()
# wait till MetaTrader 5 connects to the trade server
MT5WaitForTerminal()
# display data on connection status, server name and trading account
print(MT5TerminalInfo())
# display data on MetaTrader 5 version
print(MT5Version())
# shut down connection to the MetaTrader 5 terminal
MT5Shutdown()
Result:
>>> from datetime import datetime
>>> from MetaTrader5 import *
>>> MT5Initialize()
True
>>> MT5WaitForTerminal()
True
>>> print(MT5TerminalInfo())
[2, 'MetaQuotes-Demo', '16167573']
>>> print(MT5Version())
[500, 2009, '15 Mar 2019']
>>> MT5Shutdown()
True 

See also

MT5Initialize, MT5WaitForTerminal, MT5Shutdown, MT5Version