简体   繁体   中英

Initializing metatrader in python

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM