MetaTrader 5 Python User Group - how to use Python in Metatrader - page 70

 
Perhaps Metatrader has a setting that prevents quotes from being sent to python?
 
rale70:
Maybe Metatrader has a setting that prohibits sending quotes to python?

Run the standard example: [data folder]\MQL5\Scripts\Python\copy_rates_from.py

 
rale70:
Maybe Metatrader has a setting that prevents quotes from being sent to python?

Try this.

import MetaTrader5 as mt5
from datetime import datetime

try:
    if not mt5.initialize():
        raise Exception(mt5.last_error())
    eurusd_rates = mt5.copy_rates_from("EURUSD", mt5.TIMEFRAME_M30, datetime(2020, 1, 28, 13), 1000)
    if eurusd_rates is None:
        raise Exception(mt5.last_error())
    else:
        print(eurusd_rates)
except Exception as e:
    print('MQL_ERROR', e)
finally:
    mt5.shutdown()
 
nicholish en:

Try this.

I get this error:


MQL_ERROR (-1, 'Terminal: Call failed')

Process finished with exit code 0

 
Vladimir Karputov:

Run the standard example: [data folder]\MQL5\Scripts\Python\copy_rates_from.py

Launch it, it gives me the output:

MetaTrader5 package author: MetaQuotes Software Corp.

MetaTrader5 package version: 5.0.33

Print obtained data as is

Traceback (most recent call last):

File "C:/Users/rale/PycharmProjects/probs/proba1.py", line 32, in <module>

For rates in rates:

TypeError: 'NoneType' object is not iterable


Process finished with exit code 1

 

The problem solved itself. Maybe someone could use it.

Uninstalled Metatrader 5 from Alpari, downloaded a new one from forexclub, connected to their account and everything worked.

One of two things, either the first MT5 was wrongly installed or there's a problem with the broker.

Either way, thanks to everyone who tried to help!

 
rale70:

The problem solved itself. Maybe someone could use it.

Uninstalled Metatrader 5 from Alpari, downloaded a new one from forexclub, connected to their account and everything worked.

One of two things, either the first MT5 was wrongly installed or there's a problem with the broker.

In any case thanks to everybody who tried to help!

Maybe there is a limit on the number of bars, you need to remove this restriction in the terminal (Tools->Options->Max bars in chart).

 

Hi all.
Now it is possible to run a script in Python development environment and it will work in MT5.

Can you please tell me if it is possible to write a Python EA and run it in MT5 itself?

There are scripts, but they, as I understand, are for displaying information more, not for making trades under certain conditions.
Couldn't find a thread on the subject...



 
IvanDorofeev:

Hi all.
Now it is possible to run a script in Python development environment and it will work in MT5.

Can you please tell me if it is possible to write a Python EA and run it in MT5 itself?

There are scripts, but they, as I understand, are for displaying information more, not for making trades under certain conditions.
Couldn't find a thread on the subject...



https://www.mql5.com/ru/docs/integration/python_metatrader5/mt5ordersend_py

Документация по MQL5: Интеграция / MetaTrader для Python / order_send
Документация по MQL5: Интеграция / MetaTrader для Python / order_send
  • www.mql5.com
[in]  Структура типа MqlTradeRequest, которая описывает требуемое торговое действие. Обязательный неименованный параметр. Пример заполнения запроса и состав перечислений смотрите ниже. Идентификатор эксперта. Позволяет организовать аналитическую обработку торговых ордеров. Каждый эксперт может выставлять свой собственный уникальный...
 
Is there a plan to get glasses by instrument?