# import MetaTrader5 as mt5 # if not mt5.initialize(): # print("Connection failed:", mt5.last_error()) # else: # account = mt5.account_info() # if account: # print("Account ID:", account.login) # print("Server:", account.server) # print("Broker:", account.company) # else: # print("Failed to get account info:", mt5.last_error()) # mt5.shutdown() import MetaTrader5 as mt5 # Path to the exact MT5 terminal you want to connect to MT5_PATHWAY = r"C:\Users\wkimu\AppData\Roaming\FundedNext MT5 Terminal\terminal64.exe" # ----------------------------------- # Initialize connection to this terminal # ----------------------------------- if not mt5.initialize(path=MT5_PATHWAY): print("Connection failed") print("Error:", mt5.last_error()) else: print("Connected successfully to:", MT5_PATHWAY) # Verify which account/server is active account_info = mt5.account_info() if account_info: print(f"Account ID: {account_info.login}") print(f"Server: {account_info.server}") print(f"Broker: {account_info.company}") else: print("Could not retrieve account info:", mt5.last_error()) # Test fetching market data symbol = "EURUSD" tick = mt5.symbol_info_tick(symbol) if tick: print(f"Latest tick for {symbol}: Bid={tick.bid}, Ask={tick.ask}") else: print(f"Failed to get tick for {symbol}. Error:", mt5.last_error()) # Always shutdown when done mt5.shutdown()