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

 
Roman:

I understand correctly that for transferring calculated values and arrays from Py to mt5, there will be no such functions ?

And is it left to use - networking solutions, or to saw a module to transfer through memory?

Library for MT5 <-> Python communication with a focus on getting data.

Only queries and trade requests go to the terminal from python programs. There is no reason to transfer mass data from python, as it has no access to the variable MQL5 environment and is strictly limited to the narrow interface of queries to the terminal.


Python integration has the following application area:

  1. Receive market data charts, positions and history
  2. send and monitor trades
  3. run *.py files directly from the navigator
  4. attract Python developers to Metatrader ecosystem due to easy data access and full-fledged trading without crutches
  5. attract narrow professional groups of quant developers from hedge funds, investment firms and banks by offering them a convenient substitute for their own zoo
  6. give access to the variety of mathematical and AI libraries available in Python

The Python library is not a replacement for MQL5 and we do not accept any requests for functionality extensions.
 
Renat Fatkhullin:

Library for MT5 <-> Python communication with a focus on data acquisition.

Only queries and trade requests go to the terminal from Python programs. There is no reason to transmit mass data from Python, as it has no access to the variable MQL5 environment and is strictly limited to the narrow interface of requests to the terminal.


Python integration has the following application area:

  1. Receive market charts data, position data and trade history
  2. send and monitor trades
  3. run *.py files directly from the navigator
  4. attract Python developers to Metatrader ecosystem due to easy data access and full-fledged trading without crutches
  5. attract narrow professional groups of quant developers from hedge funds, investment firms and banks by offering them a convenient substitute for their own zoo
  6. give access to the variety of mathematical and AI libraries available in Python

The Python library is not a replacement for MQL5 and we do not accept any requests for functionality extensions.

There's that sandbox again... Perhaps you didn't understand the question and a solution can be found.
There is a need to pass an array from a Py script to an mql program.
There are reasons to pass, arrays of calculated data.
To build real time custom mql charts.
To build real-time mql indicators.
For using real-time calculations in mql experts.
Running *.py files directly from the navigator does not solve the problem of building professional custom charts in mt5.
You need mt5 custom real time charts calculated in a Py script.
For that you need array transfer from Py script.

 
Good people, could you tell me how to make pending orders here and, if possible, an example
 
Roman:

There is a need to pass an array from a Py script to an mql program.

The answer has been given in full and clear.

 
Renat Fatkhullin:

The answer was full and clear.

The answer has been read, but the reason for the restriction is not clear.
How can arrays controlled in open Py script harm mql program?
What kind of zoo are we talking about if we're going to use crutches again, same sockets, dll, etc.
This creates an artificial barrier to create professional solutions for mt5.

 
alex.alexen:
Good people, tell me how to make pending orders here and if you can, an example

There are no ready-made functions, but you can see how simple orders are made in __init__.py, pending ones are made similarly:

#  internal order send
def _RawOrder(order_type, symbol, volume, price, comment=None, ticket=None):
    order = {
      "action":    TRADE_ACTION_DEAL,
      "symbol":    symbol,
      "volume":    volume,
      "type":      order_type,
      "price":     price,
      "deviation": 10,
    }
    if comment != None:
        order["comment"] = comment
    if ticket != None:
        order["position"] = ticket
    r = order_send(order)
    return r

#  Buy order                
def Buy(symbol, volume, price=None, *, comment=None, ticket=None):
    #  with direct call
    if price != None:
        return _RawOrder(ORDER_TYPE_BUY, symbol, volume, price, comment, ticket)
    #  no price, we try several times with current price
    for tries in range(10):
        info = symbol_info_tick(symbol)
        r = _RawOrder(ORDER_TYPE_BUY, symbol, volume, info.ask, comment, ticket)
        if r.retcode != TRADE_RETCODE_REQUOTE and r.retcode != TRADE_RETCODE_PRICE_OFF:
            break
    return r

#  Sell order
def Sell(symbol, volume, price=None, *, comment=None, ticket=None):
    #  with direct call
    if price != None:
        return _RawOrder(ORDER_TYPE_SELL, symbol, volume, price, comment, ticket)
    #  no price, we try several times with current price
    for tries in range(10):
        info = symbol_info_tick(symbol)
        r = _RawOrder(ORDER_TYPE_SELL, symbol, volume, info.bid, comment, ticket)
        if r.retcode != TRADE_RETCODE_REQUOTE and r.retcode != TRADE_RETCODE_PRICE_OFF:
            break
    return r

fields passed to order_send:

action, magic, order, symbol, volume, price, stoplimit, sl, tp, deviation, type, type_filling, type_time, expiration, comment, position, position_by

they are similar: https://www.mql5.com/ru/docs/trading/ordersend

Документация по MQL5: Торговые функции / OrderSend
Документация по MQL5: Торговые функции / OrderSend
  • www.mql5.com
Торговый запрос проходит несколько стадий проверок на торговом сервере. В первую очередь проверяется корректность заполнения всех необходимых полей параметра , и при отсутствии ошибок сервер принимает ордер для дальнейшей обработки. При успешном принятии ордера торговым сервером функция OrderSend() возвращает значение true. Рекомендуется...
 

Hello.

May be the question has already been asked, but search (google, forum) didn't yield a positive result. I think I may have been able to use MetaTrader5 on a jupyter notebook installed on my Ubuntu PC. After some troubles with my PC, I changed it and installed a new HDD. After this procedure I lost connection with the package and when I try to install the package with the pip install MetaTrader5 command I get the following message:

ERROR: Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)

ERROR: No matching distribution found for MetaTrader5

Kindly advise:
1. Is it possible to install the package on a PC with Ubuntu?
2. If yes, what can I do to correct the error I receive during installation?

Документация по MQL5: Интеграция / MetaTrader для Python
Документация по MQL5: Интеграция / MetaTrader для Python
  • www.mql5.com
MT5Tick(time=datetime.datetime(2019, 4, 1, 3, 2, 3, 512000), bid=1.5764200000000002, ask=1.57837, last=0.0, volume=0.0, flags=134) MT5Tick(time=datetime.datetime(2019, 4, 1, 3, 2, 8, 70000), bid=1.57643, ask=1.57837, last=0.0, volume=0.0, flags=130...
 
wildzes:

Hello.

May be the question has already been asked, but search (google, forum) didn't yield a positive result. I think I may have been able to use MetaTrader5 on a jupyter notebook installed on my Ubuntu PC. After some troubles with my PC, I changed it and installed a new HDD. After this procedure I lost connection with the package and when I try to install the package with the pip install MetaTrader5 command I get the following message:

ERROR: Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)

ERROR: No matching distribution found for MetaTrader5

Kindly advise:
1. Is it possible to install the package on a PC with Ubuntu?
2. If yes, what can I do to correct the error I receive during installation?

No, the library is only for the Windows version of Python, as it works in conjunction with the Windows version of the terminal.

 
Renat Fatkhullin:
We'll write a new version of the integration library and add explicit selection and authorization on the desired account there .

Multi-version is supported by specifying the path to a particular version of the interpreter in the editor settings.

Packages are installed manually, this is not a problem with the environment. It is all the more dangerous to do this automatically, and on the masses of poorly understood users.

There will be no debugger, you can debug in other environments. We have no task to make a full-fledged debugger for Python, only its execution environment and integration with the terminal.


Will it be available later? Or?

 
Almaz:

There are no ready-made functions, but you can see how simple orders are done in __init__.py, pending ones are done similarly:

fields passed to order_send:

they are similar: https://www.mql5.com/ru/docs/trading/ordersend

Where does _init_.py come from ? Where can i see it?