MetaTrader 5 Python用户组 - 如何在Metatrader中使用Python - 页 37

 
Renat Fatkhullin:

从5.0.15版本开始,Python库以一种新的格式工作,与旧的格式不兼容,需要终端的最新测试版。

我们将很快发布更新的文档和实例

是否可以暂时下载旧版本的库?

 
Dmitri Custurov:

是否可以临时下载一个旧版本的库?

https://pypi.org/project/MetaTrader5/5.0.11/#files

MetaTrader5
MetaTrader5
  • 2020.01.24
  • pypi.org
Download the file for your platform. If you're not sure which to choose, learn more about installing packages. Files for MetaTrader5, version 5.0.11 Filename, size File type Python version Upload date Hashes MetaTrader5-5.0.11-cp36-cp36m-win32.whl (31.7 kB) MetaTrader5-5.0.11-cp36-cp36m-win_amd64.whl (43.3 kB...
 

我忍不住要表达一下对整合的看法。我是双手赞成的。Python、神经网络、人工智能、编译器扩展等等,等等。

但有一个BUT。

无论开发环境有多酷,它都应该是大规模的,对吗?如果它的工具包是通常的基元,那么它怎么可能是大规模的呢?不--不是通常的基元,而是基因基元。超复杂的基元。

让我们来看看CCanvas类--它是一个图形基元的集合。我们能不能集合很多人的力量?很多。但这需要多少脑力和劳力呢?- 很多。智慧和劳动的海洋,创造了THING。有多少人能够做到这一点?- 只是一些。

主要问题又来了:如果APRIORI假设一个人有不寻常的设计能力,那么开发环境工具怎么可能变得流行?在这种情况下,大规模供应是不可能的。

我将简要地转述一下。

如果一个人熟悉Python、C++、MQL5、Algotrading,并且有非凡的设计能力,那么在什么专业环境下创造他的东西对他来说有什么区别呢?他将使用最小的功能,产生最大的结果。其他人会尝试使用所有的东西,但不会创造任何东西,因为工具包的复杂性门槛。

那么,你需要关注谁,关注什么?

 

版本降低到最低的可用5.0.10

444

显然,我们将不得不等待更新。

 

向大家问好!

为什么我得到了这个错误,即使我已经按照正确的例子操作?

向大家问好!

为什么我得到了这个错误,即使我已经按照正确的例子操作?


 
Renat Fatkhullin:
在visual studio中是否启用了python?

由于不同系统间接或自动部署的python的动物园,很容易让库安装在另一个python副本中,然后尝试运行其他副本。

请整理一下蟒蛇。那些转向Python的人必须准备好在他们的余生中与库、依赖关系和不相容性作斗争。

这就是一个Python主义者的命运--建立一个库的环境,并祈祷一些库的更新不会弄乱另一个未知数量的库。

没有Python动物园。有一个环境。可能有一个以上的环境。用户选择使用哪个环境。

在运行脚本之前,应该对Python环境进行初始化。

在图书馆 里考虑过这个问题。这里是环境初始化函数代码。

MetaTrader 5 (MQL5) + Python 3 DLL для Forex, CFD и Futures
  • roffild.com
Использование MetaTrader с Python 3 на финансовых фондовых биржах, Forex, CFD и Futures. Из MetaTrader можно получать котировки в Python, но нет полноценной связи между ними. Пост одного из разработчиков. Главная идея и отличие этой обертки от остальных: обмен данными между MQL и Python через заранее созданные функции. Это самый быстрый и...
 

也许现在是放弃MetaEditor的时候了?如果你能得到一个成熟的现成的IDE,为什么还要把不同的技术塞进你的IDE?

如今,每个人都在为IDE创建一个模块。

微软视觉工作室 代码

智慧的力量

 
Roffild:

没有Python动物园。有一个环境的概念。一台计算机上可能有几个环境。这取决于用户选择使用哪种环境。

在运行脚本之前,应该对Python环境进行初始化。

在图书馆 里考虑过这个问题。下面是环境初始化函数的代码。

我们很容易支持环境。请看一下编辑器中的编译器设置。

我的意思是说,终端可以选择一个环境(例如默认路径),而库将被用户手动放到另一个环境中。


明天我们将发布一个新的终端测试版和一个新的python库。所有旧的方法和例子都被破坏了,因为我们已经从头开始重写了api和库。

新的一套api很宽泛,允许你完全管理交易,并可以访问未结头寸和历史。

现在你可以直接用Python编写成熟的Metatrader机器人。

 

新版本的MetaTrader 5 for Python 5.0.18和MetaTrader 5 build 2319 beta。

  • 通过帮助->检查测试版下载MT5测试版
  • python库。
    pip install --upgrade metatrader5
    

由于所有的api已经改变,旧的例子不再起作用。

以下是新的功能设置。

initialize(path=None)                              Establish connection with the MetaTrader 5 Terminal
wait()                                             Wait for the MetaTrader 5 Terminal to connect to a broker's server
shutdown()                                         Disconnect from the MetaTrader 5 Terminal

version()                                          Get the MetaTrader 5 Terminal version
terminal_info()                                    Get the parameters of the MetaTrader 5 terminal
account_info()                                     Returns information of current account

copy_ticks_from(symbol, from, count, flags)                Get ticks starting from the specific date
copy_ticks_range(symbol, from, to, flags)                  Get ticks from the specified period
copy_rates_from(symbol, timeframe, from, count)            Get bars starting from the specific date
copy_rates_from_pos(symbol, timeframe, start_pos, count)   Get bars starting from the specified position
copy_rates_range(symbol, timeframe, date_from, date_to)    Get bars from the specified period

positions_total()                                          Returns the number of open positions
positions_get([symbol=\"SYMBOL\"],[ticket=TICKET])         Returns all open positions, can be filtered by symbol or ticket

orders_total()                                             Returns the number of orders
orders_get([symbol=\"SYMBOL\"],[ticket=TICKET])            Returns all orders, can be filtered by symbol or ticket

history_orders_total(from, to)                             Returns the number of orders in selected range from the history
history_orders_get(from, to)                               Returns orders in selected range from the history or filtered by position id, ticket

history_deals_total(from, to)                              Returns the number of deals in selected range from the history
history_deals_get(from, to)                                Returns deals in selected range from the history or filtered by position id, ticket

order_check(request)                                                Checks if there are enough funds to execute the required trade operation
order_send(request)                                                 Sends trade requests to a server
order_calc_margin(action, symbol, volume, price)                    Calculates the margin required for the specified order
order_calc_profit(action, symbol, volume, price_open, price_close)  Calculates the profit for the current account, in the current market conditions, based on the parameters passed

symbol_info(symbol)                                        Returns full information for a specified symbol
symbol_info_tick(symbol)                                   Returns current prices of a specified symbol
symbol_select(symbol,[enable])                             Selects a symbol in the Market Watch window or removes a symbol from the window

例子。

import MetaTrader5 as mt5
import time

mt5.initialize()
mt5.wait()

dev = 0.00010;
symbol = "EURUSD"
buy_price = 0

mt5.symbol_select(symbol)

time.sleep(1)
p = mt5.symbol_info_tick(symbol)
prev_price = p.ask

while True:
    p = mt5.symbol_info_tick(symbol)
    print(p.bid,'/',p.ask)
    
    if p.ask > prev_price and buy_price == 0:
            print("Buy ", p.ask)
            r = mt5.Buy(symbol, 0.01)
            if r.retcode == mt5.TRADE_RETCODE_DONE:
                buy_price = p.ask;
    elif buy_price > 0 and p.ask + dev < buy_price:
        print("Buy(close) ", p.bid)
        mt5.Close(symbol)
        buy_price = 0

    prev_price = p.ask
    time.sleep(1)

mt5.shutdown()
 
Renat Fatkhullin:

新版本的MetaTrader 5 for Python 5.0.18和MetaTrader 5 build 2319 beta。

  • 通过帮助->检查测试版下载MT5测试版
  • python库。

由于所有的api已经改变,旧的例子不再起作用。

一切都在动态地变化。

不太想被卷入这个混乱的局面。

也许值得等待WinML与ONNX 的实现。而在这之前要深入研究ML的理论。 幸运的是,现在有很多可用的文献和各种课程。