首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python MetaTrader5指示器

Python MetaTrader5指示器
EN

Stack Overflow用户
提问于 2020-02-26 06:39:54
回答 1查看 3.1K关注 0票数 1

我正在使用python的Metatrader5模块,这是我的代码

‘#python

代码语言:javascript
复制
from datetime import datetime
import MetaTrader5 as mt5

# display data on the MetaTrader 5 package
print("MetaTrader5 package author: ", mt5.__author__)
print("MetaTrader5 package version: ", mt5.__version__)

# import the 'pandas' module for displaying data obtained in the tabular form
import pandas as pd

pd.set_option('display.max_columns', 500)  # number of columns to be displayed
pd.set_option('display.width', 1500)  # max table width to display
# import pytz module for working with time zone
import pytz

# establish connection to MetaTrader 5 terminal
if not mt5.initialize():
print("initialize() failed")
mt5.shutdown()

# set time zone to UTC
timezone = pytz.timezone("Etc/UTC")
# create 'datetime' object in UTC time zone to avoid the implementation of a local time zone offset
utc_from = datetime(2020, 1, 10, tzinfo=timezone)
# get 10 EURUSD H4 bars starting from 01.10.2020 in UTC time zone
rates = mt5.copy_rates_from("EURUSD", mt5.TIMEFRAME_H4, utc_from, 10)

# shut down connection to the MetaTrader 5 terminal
mt5.shutdown()
# display each element of obtained data in a new line
print("Display obtained data 'as is'")
for rate in rates:
print(rate)
# create DataFrame out of the obtained data
rates_frame = pd.DataFrame(rates)
# convert time in seconds into the datetime format
rates_frame['time'] = pd.to_datetime(rates_frame['time'], unit='s')

# display data
print("\nDisplay dataframe with data")
print(rates_frame)  

“”“

我的问题是,是否有任何简单的方法来计算股票指标,如RSI和MFI以及使用此模块的其他指标?

EN

回答 1

Stack Overflow用户

发布于 2020-03-26 22:05:34

不是的。不过,如果使用其他模块也是可能的。

下面是一个使用另一个可以实现它的方法:https://www.mql5.com/en/articles/5691

或者,您可以从MT5中提取数据并将其放入TA-lib中进行分析。TA-lib使用数据并为MT5之外的指示器提供值。

查看TA-lib:https://mrjbq7.github.io/ta-lib/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60404229

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档