1.How can I import my script into Metatrader 5
2.for instance , If I use the the below code, the script in Metatrader 5 works well or I should run this script in among a loop?
I mean that , the metatrader run my script base on this date or not? data = pd.DataFrame(mt.copy_rates_range("EURUSD", mt.TIMEFRAME_H4,datetime(2022,1,12),datetime.now())) I really confuse, is there any one here to help me please..
MetaTrader only runs compiled MQL5 code, not Python. You don't import Python code into MetaTrader 5. The Python code runs on its own outside of MetaTrader and uses the API to access the MT5 terminal data and interact with it.
MetaTrader only runs compiled MQL5 code, not Python. You don't import Python code into MetaTrader 5. The Python code runs on its own outside of MetaTrader and uses the API to access the MT5 terminal data and interact with it.
Thanks for your reply.
But I visit some youtube chanel that run the script python import to script metatrader.
My problem is, I don't know how meta trader run this kind of script. for instance I don't know is meta trader run this script for once or it runs for several times?
I repeat — there is no MetaTrader "import" of Python scripts. The python script runs in Python and it accesses the MT5 terminal via its integration package.
Read the documentation: MetaTrader module for integration with Python

- www.mql5.com
I have no experience to run python script inside MQL5. But I am willing to share my experience to run python/Metatrader5. Here is my python setup: VS Code is my python IDE, MetaTrader5 package is installed. Most importantly, MT5 terminal has to be up running with successful login.
First of all, we have to initialize mt5 for python usage. Modify my code accordingly:
import MetaTrader5 as mt5 def init_mt5(msg=True): path = r'C:\Program Files\MetaTrader 5' TERMINAL = r'\terminal64.exe' terminal = path + TERMINAL if not mt5.initialize(terminal): print("initialize() failed, error code =",mt5.last_error()) quit() acct_info = mt5.account_info()._asdict() term_info = mt5.terminal_info()._asdict() if msg == True: print('********** Summary of Login/Terminal Information *************') print('Login Account: ', acct_info['login']) print('Account Name: ', acct_info['name']) print('Login Server: ', acct_info['server']) print('Account Leverage: ', acct_info['leverage']) print('Account Balance: ', acct_info['balance']) print('Account Buying Power in Million: ', round(acct_info['leverage'] * acct_info['balance'] / 1_000_000, 3)) print('Terminal: ', term_info['name']) print('Terminal Connected: ', term_info['connected']) print('Trade Allowed: ', term_info['trade_allowed']) print('Trade API Disabled: ', term_info['tradeapi_disabled']) print('************ End of Login/Terminal Information ***************') init_mt5() mt5.shutdown()
Below is the screenshot of output. After successful initialization, you can do whatever described in MQL5 python reference such as copy_rates.
Fernando Carreiro #:
I repeat — there is no MetaTrader "import" of Python scripts. The python script runs in Python and it accesses the MT5 terminal via its integration package.
Read the documentation: MetaTrader module for integration with Python
Hi,
On clicking the link, it says "404. The page does not exist"
Could you please confirm the link.
Thanks.

- www.mql5.com
MetaQuotes has changed their documentation. Here is the new link ... Documentation on MQL5: Python Integration
Could you please help me on How to load an EA from Python script?
The Python API and MQL5 EAs are two completely different things. The API is not for "loading" EAs. It for coding algorithmic programs equivalent to an EA but in Python.
To have MetaTrader startup with a specific EA, use the normal command line with a configuration — Platform Start - For Advanced Users - Getting Started - MetaTrader 5 Help


- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi dear friends,
I wrote a python script, as far as I know , this kind of script gets some data as input like from_date to to_date.
suppose I want analyses some data between two dates, It will work correctly .
Just I have some question :
1.How can I import my script into Metatrader 5
2.for instance , If I use the the below code, the script in Metatrader 5 works well or I should run this script in among a loop?
I mean that , the metatrader run my script base on this date or not?
data = pd.DataFrame(mt.copy_rates_range("EURUSD", mt.TIMEFRAME_H4,datetime(2022,1,12),datetime.now()))
I really confuse, is there any one here to help me please..