初学者的问题 MQL5 MT5 MetaTrader 5 - 页 83

 

我遇到了一个问题--当在某一点进行测试时,不知什么原因,出现了 "无效止损 "的错误,但止损是正确的。

这个算法很简单--把一个订单

   MqlTradeResult result = { 0 };
   MqlTradeRequest request = { 0 };
   
   double price = SymbolInfoDouble(_Symbol, isBuy ? SYMBOL_ASK : SYMBOL_BID);
   double sl = price - lvl * _Point;
   double tp = price + lvl * _Point;

   request.action = TRADE_ACTION_DEAL;
   request.magic = magic;
   request.symbol = _Symbol;
   request.volume = lot;
   request.price = price;
   request.deviation = deviation;
   request.type = isBuy ? ORDER_TYPE_BUY : ORDER_TYPE_SELL;

   OrderSend(request, result);

   order = result.order;
   
   if (order)
   {   
      ZeroMemory(result);
      ZeroMemory(request);

      request.action = TRADE_ACTION_SLTP;
      request.order = order;
      request.symbol = _Symbol;
      request.sl = isBuy ? sl : tp;
      request.tp = isBuy ? tp : sl;

      if (!OrderSend(request, result))
      {
         Print(" --- Can not modify order --- error = " + GetLastError() + " order = " + order + " price = " + price);
      }
   }

当它被关闭时,重复程序

结果,我得到了这样的结果(我在2010.05.01开始)。

2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00    --- Can not modify order --- error = 4756 order = 4720 price = 1.41795
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   failed modify sell 0.10 EURUSD sl: 0.00000, tp: 0.00000 -> sl: 1.42095, tp: 1.41495 [Invalid stops]
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   order performed sell 0.10 at 1.41795 [#4720 sell 0.10 EURUSD at 1.41795]
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   deal performed [#4720 sell 0.10 EURUSD at 1.41795]
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   deal #4720 sell 0.10 EURUSD at 1.41795 done (based on order #4720)
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   exchange sell 0.10 EURUSD at 1.41795 (1.41795 / 1.42399 / 1.41795)
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   order performed buy 0.10 at 1.42003 [#4719 buy 0.10 EURUSD at 1.42003]
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   deal performed [#4719 buy 0.10 EURUSD at 1.42003]
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   deal #4719 buy 0.10 EURUSD at 1.42003 done (based on order #4719)
2013.01.16 13:22:16     Core 1  2011.03.18 21:59:00   stop loss triggered sell 0.10 EURUSD 1.41703 sl: 1.42003 tp: 1.41403 [#4719 buy 0.10 EURUSD at 1.42003]
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   position modified [sell 0.10 EURUSD 1.41703 sl: 1.42003 tp: 1.41403]
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   order performed sell 0.10 at 1.41703 [#4718 sell 0.10 EURUSD at 1.41703]
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   deal performed [#4718 sell 0.10 EURUSD at 1.41703]
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   deal #4718 sell 0.10 EURUSD at 1.41703 done (based on order #4718)
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   exchange sell 0.10 EURUSD at 1.41703 (1.41703 / 1.41711 / 1.41703)
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   order performed buy 0.10 at 1.41711 [#4717 buy 0.10 EURUSD at 1.41711]
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   deal performed [#4717 buy 0.10 EURUSD at 1.41711]
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   deal #4717 buy 0.10 EURUSD at 1.41711 done (based on order #4717)
2013.01.16 13:22:16     Core 1  2011.03.18 17:37:33   stop loss triggered sell 0.10 EURUSD 1.41411 sl: 1.41711 tp: 1.41111 [#4717 buy 0.10 EURUSD at 1.41711]
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   position modified [sell 0.10 EURUSD 1.41411 sl: 1.41711 tp: 1.41111]
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   order performed sell 0.10 at 1.41411 [#4716 sell 0.10 EURUSD at 1.41411]
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   deal performed [#4716 sell 0.10 EURUSD at 1.41411]
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   deal #4716 sell 0.10 EURUSD at 1.41411 done (based on order #4716)
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   exchange sell 0.10 EURUSD at 1.41411 (1.41411 / 1.41420 / 1.41411)
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   order performed buy 0.10 at 1.41420 [#4715 buy 0.10 EURUSD at 1.41420]
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   deal performed [#4715 buy 0.10 EURUSD at 1.41420]
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   deal #4715 buy 0.10 EURUSD at 1.41420 done (based on order #4715)
2013.01.16 13:22:16     Core 1  2011.03.18 13:29:27   stop loss triggered sell 0.10 EURUSD 1.41120 sl: 1.41420 tp: 1.40820 [#4715 buy 0.10 EURUSD at 1.41420]
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   position modified [sell 0.10 EURUSD 1.41120 sl: 1.41420 tp: 1.40820]
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   order performed sell 0.10 at 1.41120 [#4714 sell 0.10 EURUSD at 1.41120]
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   deal performed [#4714 sell 0.10 EURUSD at 1.41120]
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   deal #4714 sell 0.10 EURUSD at 1.41120 done (based on order #4714)
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   exchange sell 0.10 EURUSD at 1.41120 (1.41120 / 1.41126 / 1.41120)
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   order performed buy 0.10 at 1.41126 [#4713 buy 0.10 EURUSD at 1.41126]
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   deal performed [#4713 buy 0.10 EURUSD at 1.41126]
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   deal #4713 buy 0.10 EURUSD at 1.41126 done (based on order #4713)
2013.01.16 13:22:16     Core 1  2011.03.18 11:56:13   stop loss triggered sell 0.10 EURUSD 1.40826 sl: 1.41126 tp: 1.40526 [#4713 buy 0.10 EURUSD at 1.41126]
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   position modified [sell 0.10 EURUSD 1.40826 sl: 1.41126 tp: 1.40526]
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   order performed sell 0.10 at 1.40826 [#4712 sell 0.10 EURUSD at 1.40826]
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   deal performed [#4712 sell 0.10 EURUSD at 1.40826]
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   deal #4712 sell 0.10 EURUSD at 1.40826 done (based on order #4712)
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   exchange sell 0.10 EURUSD at 1.40826 (1.40826 / 1.40835 / 1.40826)
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   order performed buy 0.10 at 1.40832 [#4711 buy 0.10 EURUSD at 1.40832]
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   deal performed [#4711 buy 0.10 EURUSD at 1.40832]
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   deal #4711 buy 0.10 EURUSD at 1.40832 done (based on order #4711)
2013.01.16 13:22:16     Core 1  2011.03.18 11:00:28   stop loss triggered sell 0.10 EURUSD 1.40532 sl: 1.40832 tp: 1.40232 [#4711 buy 0.10 EURUSD at 1.40832]
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   position modified [sell 0.10 EURUSD 1.40532 sl: 1.40832 tp: 1.40232]
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   order performed sell 0.10 at 1.40532 [#4710 sell 0.10 EURUSD at 1.40532]
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   deal performed [#4710 sell 0.10 EURUSD at 1.40532]
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   deal #4710 sell 0.10 EURUSD at 1.40532 done (based on order #4710)
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   exchange sell 0.10 EURUSD at 1.40532 (1.40532 / 1.40542 / 1.40532)
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   order performed buy 0.10 at 1.40543 [#4709 buy 0.10 EURUSD at 1.40543]
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   deal performed [#4709 buy 0.10 EURUSD at 1.40543]
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   deal #4709 buy 0.10 EURUSD at 1.40543 done (based on order #4709)
2013.01.16 13:22:16     Core 1  2011.03.18 09:56:28   take profit triggered sell 0.10 EURUSD 1.40843 sl: 1.41143 tp: 1.40543 [#4709 buy 0.10 EURUSD at 1.40543]
2013.01.16 13:22:16     Core 1  2011.03.18 09:00:37   position modified [sell 0.10 EURUSD 1.40843 sl: 1.41143 tp: 1.40543]
2013.01.16 13:22:16     Core 1  2011.03.18 09:00:37   order performed sell 0.10 at 1.40843 [#4708 sell 0.10 EURUSD at 1.40843]
2013.01.16 13:22:16     Core 1  2011.03.18 09:00:37   deal performed [#4708 sell 0.10 EURUSD at 1.40843]
2013.01.16 13:22:16     Core 1  2011.03.18 09:00:37   deal #4708 sell 0.10 EURUSD at 1.40843 done (based on order #4708)
2013.01.16 13:22:16     Core 1  2011.03.18 09:00:37   exchange sell 0.10 EURUSD at 1.40843 (1.40843 / 1.40852 / 1.40843)
...

问题可能是什么?(当时我80%的存款是免费的)

 
Forux: 遇到了一个问题--当在某个点测试时,由于未知的原因,出现了 "无效的停止 "的错误,但停止是正确的。

这就是我们最后的结果(从2010.05.01开始)。

可能是什么问题?(当时80%的存款是免费的)

错误信息 是针对位置修改而弹出的。同时,在代码中没有检查sl/tp水平与当前价格的允许距离。可能发生的情况是,当前市场价格接近sl或tp水平的距离比服务器允许的距离短。在ORDER_STOPS_LEVEL 手册中查看
 
Yedelkin:
错误信息 是针对位置修改而弹出的。该代码没有检查sl/tp水平与当前价格的允许距离。可能发生的情况是,在处理两个交易请求 时,当前市场价格已经接近sl或tp水平,超过了服务器允许的距离。在ORDER_STOPS_LEVEL 手册中查看

对代码进行了修改,以进行检查。

price = SymbolInfoDouble(_Symbol, isBuy ? SYMBOL_ASK : SYMBOL_BID);
Print(" --- Can not modify order --- error = " + GetLastError() + " order = " + order + " price = " + price);

因此,误差线没有变化(即价格没有变化)。而且它可能无法做到,它是在分钟上、在阿尔帕里历史上(98%的历史质量)进行了两年半的测试。

这看起来更像是MetaTrader本身的错误,因为在此之前,同样的事情也发生了,但没有错误。

 
Forux:对代码进行了修改,以进行检查。
那么,你也检查过允许的缩进吗?
 
Yedelkin:
Ну а проверку на допустимый отступ тоже сделали?
Yedelkin
:

你是否也检查过允许的压痕?

试验中允许的距离是0。而且价格没有变化,出错后与修改前创建订单时的价格相同。

price = SymbolInfoDouble(_Symbol, isBuy ? SYMBOL_ASK : SYMBOL_BID);
Print("SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL) == " + SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL));
Print(" --- Can not modify order --- error = " + GetLastError() + " isBuy = " + isBuy + " order = " + order +  " price = " + price);

纪录

2013.01.16 14:32:28     Core 1  2011.03.18 21:59:00    --- Can not modify order --- error = 4756 isBuy = false order = 4720 price = 1.41795
2013.01.16 14:32:28     Core 1  2011.03.18 21:59:00   SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL) == 0
2013.01.16 14:32:28     Core 1  2011.03.18 21:59:00   failed modify sell 0.10 EURUSD sl: 0.00000, tp: 0.00000 -> sl: 1.42095, tp: 1.41495 [Invalid stops]
2013.01.16 14:32:28     Core 1  2011.03.18 21:59:00   order performed sell 0.10 at 1.41795 [#4720 sell 0.10 EURUSD at 1.41795]
2013.01.16 14:32:28     Core 1  2011.03.18 21:59:00   deal performed [#4720 sell 0.10 EURUSD at 1.41795]
2013.01.16 14:32:28     Core 1  2011.03.18 21:59:00   deal #4720 sell 0.10 EURUSD at 1.41795 done (based on order #4720)
2013.01.16 14:32:28     Core 1  2011.03.18 21:59:00   exchange sell 0.10 EURUSD at 1.41795 (1.41795 / 1.42399 / 1.41795)
...
 
Forux: 而且价格没有变化,出错后与修改前创建订单时的价格相同。

价格本身(一般来说)最初可能比服务器目前允许的水平更接近。因此,最好总是检查这样的情况。

Forux :测试中允许的距离是0。

是的,现在很清楚,在这种情况下,检查缩进并不能解决问题。我是否正确理解了卖出头寸的sl/tp水平是根据买入价设置的?

 
Yedelkin:

价格本身(一般来说)最初可能比服务器目前允许的水平更接近。因此,最好总是检查这种情况。

是的,现在很清楚,在这种情况下,检查缩进并不能解决问题。我是否正确理解了卖出头寸的sl/tp水平是根据买入价设置的?

是的,根据订单类型,进入和退出都是在卖出价或买入价。
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
Forux: 是的,根据订单类型,进场和出场都是通过升水或出价。
我是否正确理解了卖出头寸 的sl/tp水平是根据买入价 设置的?如果不难,请打印出问题区域的当前卖出价、买入价、SL和TP。
 
Yedelkin:
我是否正确理解了卖出头寸 的sl/tp水平是根据买入价 设置的?如果不难,请打印出问题区域的当前卖出价、买入价、SL和TP。
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00    --- Can not modify order --- error = 4756 isBuy = false order = 4720 price = 1.41795
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   TP == 1.41495
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   SL == 1.42095
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   BID == 1.41795
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   ASK == 1.42399
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL) == 0
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   failed modify sell 0.10 EURUSD sl: 0.00000, tp: 0.00000 -> sl: 1.42095, tp: 1.41495 [Invalid stops]
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   order performed sell 0.10 at 1.41795 [#4720 sell 0.10 EURUSD at 1.41795]
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   deal performed [#4720 sell 0.10 EURUSD at 1.41795]
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   deal #4720 sell 0.10 EURUSD at 1.41795 done (based on order #4720)
2013.01.16 15:55:57     Core 1  2011.03.18 21:59:00   exchange sell 0.10 EURUSD at 1.41795 (1.41795 / 1.42399 / 1.41795)
...
问题删除。(好吧,还有传播o_o)。
 

你好!以前没有MT-5方案,但现在他们已经开始在 "信号 "部分给我了

我不需要任何信息。我使用移动互联网,并为每个Mb付费。

而这些信号使互联网的消费增加了3-4倍。

问题:如何配置哪些地方不接收这些信号?我没有订阅过任何信号。