MetaTrader5 library in Python 3.7

I am trying to analyze currency data using MT5 in Python but it is not working. I didn't understand where is the problem? even importing is not work

from MetaTrader5 import *
from datetime import date

# Initializing MT5 connection 
MT5Initialize()
MT5WaitForTerminal()

print(MT5TerminalInfo())
print(MT5Version())

This is the error:

MT5WaitForTerminal()RuntimeError: No IPC connection

Upvotes: 0

Views: 4589

Answers (2)

justanotherguest
justanotherguest

Reputation: 11

I have a computer with a Windows 10 64-bit installation where everything would work without a hitch. I also have another machine with a Windows 10 32-bit installation, which would always complain about an invalid IPC connection. Not the official MetaTrader 5 version, nor my broker's customized version would work out of the box.

I eventually fixed it by specifying the path to my broker's exe in the initialize function like below (check for your own path, and mind the use of / instead of \):

mt5.initialize("C:/Program Files (x86)/GT247/terminal.exe")

Upvotes: 1

user2125492
user2125492

Reputation:

I had the same issue and I found the following solution: My terminal was downloaded from the broker site and probably had some modifications that block ipc connections. I downloaded original software from https://www.metatrader5.com/en/download and copied "Config" folder from broker's version.

Now python script works.

Upvotes: 2

Related Questions