我尝试使用CopyRates()
到(所有时限搜索几个时限看涨吞没烛台模式(看跌蜡烛,随后一个更大的看涨蜡烛)H2
,以M10
一个内H4
看涨的蜡烛它关闭后)。我阅读了 的定义,CopyRates()
但我发现实施起来有点困难。这里的想法来自我想要过滤具有最大看跌与看涨蜡烛对比率的模式的模式。看看我在下面做了什么:
在OnTick()
:
for (int i=ArraySize(timeframes); i>=1; i--) {
if(CopyRates(Symbol(), timeframes[i - 1], 1, MyPeriod, rates)!=MyPeriod) {
Print("Error CopyRates errcode = ",GetLastError());
return;
}
// Using bullish engulfing pattern:
if ((rates[numCandle].open < rates[numCandle].close) &&
(rates[numCandle + 1].open > rates[numCandle + 1].close) &&
(rates[numCandle + 1].open < rates[numCandle].close) &&
(rates[numCandle + 1].close > rates[numCandle].open)) {
// Not too certain what should be done here
}
}
Run Code Online (Sandbox Code Playgroud)
这是其他相关代码:
input int …
Run Code Online (Sandbox Code Playgroud) 我无法通过以下方式安装 MetaTrader5:
pip 安装 MetaTrader5
我收到以下错误:
错误:找不到满足 MetaTrader5 要求的版本(来自版本:无)错误:找不到 MetaTrader5 的匹配发行版
知道我使用的是 MAC 笔记本电脑并且我有 Python 3.7.6
预先感谢为我提供解决方案
我正在尝试使用以下命令安装 Python 包 MetaTrader\xc2\xa05
\npython3 -m pip install MetaTrader5\n
Run Code Online (Sandbox Code Playgroud)\n我什至尝试过
\npip install MetaTrader5\n
Run Code Online (Sandbox Code Playgroud)\n但它会抛出以下错误:
\npython3 -m pip install MetaTrader5\n
Run Code Online (Sandbox Code Playgroud)\n我在用:
\n我怎样才能解决这个问题?
\n我想开一个订单,没问题,但是如果我想关闭这个订单,我需要票号,票我不能手动写,开单后会给。
从文档中,我得到了这个:
但我不能将 0 以外的任何东西传递给"position": 0
(第 20 行),否则它不会打开订单。
同时,如果 position = 0,它将打开一个订单,我将从 中获得一个持仓单result.order
,然后我必须手动将其复制并粘贴到position
来自关闭订单功能中,就像它将关闭订单一样。
那么,有没有一种方法可以不在每个打开的订单后手动复制票号并将其粘贴到关闭功能中?或者提前为打开和关闭订单写一张独特的票?
先感谢您!
import MetaTrader5 as mt5
if not mt5.initialize():
print("initialize() failed, error code =",mt5.last_error())
quit()
symbol = "EURUSD"
lot = 0.1
point = mt5.symbol_info(symbol).point
price = mt5.symbol_info_tick(symbol).ask
deviation = 20
def buy():
request = {
"action": mt5.TRADE_ACTION_DEAL,
"symbol": symbol,
"volume": lot,
"type": mt5.ORDER_TYPE_BUY,
"price": price,
"position": 0, # can't pass anything else than 0 here, otherwise it will not …
Run Code Online (Sandbox Code Playgroud) 我试图搜索找出如何在一定时间范围内搜索模式。显然,该模式可能会根据时间范围出现几次,这就是为什么我对重复的最大次数特别感兴趣。
为了说明我要进一步实现的目标,请说我正在搜索从2小时到15分钟图表的模式,然后在2小时图表中找到它,然后再钻入下一个1小时的时间范围,最后得出在1小时图上的两个模式中,我将继续30分钟(两个1小时模式)和15分钟,直到获得最大的时间。
我认为将需要一种返回下一个较低时间范围的方法。我已经能够写出来,请参见下面的代码。我真的很感谢您的帮助。
ENUM_TIMEFRAMES findLowerTimeframe(ENUM_TIMEFRAMES timePeriod)
{
int timeFrames[5] = {15, 20, 30, 60, 120};
int TFIndex=ArrayBsearch(timeFrames, (int)timePeriod);
return((ENUM_TIMEFRAMES) timeFrames[TFIndex - 1]);
}
Run Code Online (Sandbox Code Playgroud)
编辑
我没有添加特定的烛台图案,因为我认为这不是我的问题中最重要的部分。问题的症结在于如何在几个连续的时间框架内搜索模式,以找到该模式在该时间范围内出现的最大次数。
我一直在使用 2 条移动平均线交叉,这是非常直接的。我想在混合中添加三分之一,我试图找出在 4 根蜡烛或更少的时间内检查是否发生这种情况。
对于两个移动平均线,我使用了以下内容:
// if shift5MA > shift0MA
if (shift5MAArray[1] > shift0MAArray[1]) {
//if shift5MA < shift0MA VALID SELL
if (shift5MAArray[2] < shift0MAArray[2]) {
signal = "sell";
}
}
if (shift5MAArray[1] < shift0MAArray[1]) {
//if shift5MA > shift0MA
if (shift5MAArray[2] > shift0MAArray[2]) {
signal = "buy";
}
}
Run Code Online (Sandbox Code Playgroud)
我如何检查 3 条移动平均线何时在 4 根蜡烛或更少的时间内相互交叉,如图像中的三个交叉:
我正在构建一个基于 Node.JS 的系统,用于连接 MetaTrader 并处理所有操作,例如链接帐户、打开、关闭交易订单...
但是我仍然没有找到如何在 Nodejs 中连接 MetaTrader 的方法。你能给我一个解决方案或包的例子,可以帮助我做到这一点吗?谢谢!
distributed-system algorithmic-trading node.js metatrader4 metatrader5
我已经使用 MQL5 创建了一个指标。
分析后,我读到的程序说我的 CPU 的 99% 被我的OnCalculate()
.
这是我的功能:
int OnCalculate( const int rates_total,
const int prev_calculated,
const int begin,
const double &price[]
)
{
//--- check for bars count
float tempprice[];
ArrayResize( tempprice, ArraySize( price ) );
if ( rates_total < InpMAPeriod - 1 + begin ) return( 0 ); // not enough bars for calculation
//--- first calculation or number of bars was changed
if ( prev_calculated == 0 ) ArrayInitialize( ExtLineBuffer, 0 );
ArrayCopy( tempprice, …
Run Code Online (Sandbox Code Playgroud) 我在MQL5中编写了一个用于创建指标的函数.这里我附上了指标文件.
以下是OnCalculate()
指标:
int OnCalculate(const int rates_total, const int prev_calculated,const int begin,const double &price[])
{
//--- check for bars count
if(rates_total<InpMAPeriod-1+begin)
return(0);// not enough bars for calculation
//--- first calculation or number of bars was changed
if(prev_calculated==0)
ArrayInitialize(ExtLineBuffer,0);
//--- sets first bar from what index will be draw
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpMAPeriod-1+begin);
switch(InpMAMethod)
{
case MODE_EMA: //CalculateEMA(rates_total,prev_calculated,begin,price);
Execute_Me(price,"CalculateEMA",rates_total,prev_calculated,begin);
break;
case MODE_LWMA: //CalculateLWMA(rates_total,prev_calculated,begin,price);
Execute_Me(price,"CalculateLWMA",rates_total,prev_calculated,begin);
break;
case MODE_SMMA: //CalculateSmoothedMA(rates_total,prev_calculated,begin,price);
Execute_Me(price,"CalculateSmoothedMA",rates_total,prev_calculated,begin);
break;
case MODE_SMA:
Execute_Me(price,"CalculateSimpleMA",rates_total,prev_calculated,begin);
break;
}
return(rates_total);
}
Run Code Online (Sandbox Code Playgroud)
请帮助我将功能转换为基于GPU而不是基于CPU.另外,请告诉我使用系统GPU的建议.
已提交,已获取:
int Execute_Me( …
Run Code Online (Sandbox Code Playgroud) 我一直在试图弄清楚如何将我的 MQL4 代码更改为 MQL5。到目前为止,我已经能够更改 RSI 和 MACD 条件以及 SendOrder(),但是还有很多,例如 ModifyOrder() 和 CloseOrder() 以及我无法完成的其他事情。我知道这是一口口水,但我真的很感激在完成这个过程中得到一些帮助。
这是原始 MQL4 代码:
extern int MagicNumber=112223;
extern double Lots =0.005;
extern double StopLoss=0;
extern double TakeProfit=0;
extern int TrailingStop=0;
extern int Slippage=3;
int mode_main = 0;
int mode_signal = 1;
//+------------------------------------------------------------------+
// expert start function
//+------------------------------------------------------------------+
int start()
{
double MyPoint=_Point;
if(Digits==3 || Digits==5) MyPoint=Point*10;
double TheStopLoss=0;
double TheTakeProfit=0;
if( TotalOrdersCount()==0 )
{
int result=0;
if((iMACD(NULL,PERIOD_M5,12,26,9,PRICE_CLOSE,mode_signal,0)<iMACD(NULL,PERIOD_M5,12,26,9,PRICE_CLOSE,mode_main,0))&&(iRSI(NULL,PERIOD_M5,2,PRICE_CLOSE,0)>84)) // Here is your open buy rule
{
result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"EA",MagicNumber,0,Blue);
if(result>0)
{ …
Run Code Online (Sandbox Code Playgroud) metatrader5 ×10
mql5 ×7
python ×2
c++ ×1
gpu ×1
indicator ×1
metatrader4 ×1
node.js ×1
opencl ×1
pip ×1
python-3.x ×1