Initializing metatrader in python
Asked Answered
C

1

6

I am trying to use the Metatrader library to extract market data and build algorithms. The first lines to get started with this library just don't work

import MetaTrader5 as mt5
mt5.initialize()

These lines of code always return an output of False meaning that mt5 has not initialized, i have not seen this issue addressed anywhere else so i would really appreciate some help.

Corie answered 18/8, 2020 at 15:55 Comment(0)
B
7

You need to precise your login, your password, your server and download the MetaTrader 5 terminal EXE file() in order to connect to Metatrader.

if not mt5.initialize(login=25115284, server="MetaQuotes-Demo",password="4zatlbqx"):
    print("initialize() failed, error code =",mt5.last_error())
    quit()

(cf. https://www.mql5.com/en/docs/integration/python_metatrader5/mt5initialize_py)

You should also take a look at the last_error() section (https://www.mql5.com/en/docs/integration/python_metatrader5/mt5lasterror_py) of the Metatrader documentation and install Metatrader if it's not already https://www.metatrader5.com/en/automated-trading

Become answered 18/8, 2020 at 16:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.