简体   繁体   English

评论未在交易 MQL4 中使用

[英]Comment not being used in trade MQL4

Unfortunately I am not able to post the code I am debugging as it is not mine and I am bound not to show it... BUT I will describe it as detailed as possible.不幸的是,我无法发布我正在调试的代码,因为它不是我的,而且我一定不会展示它......但我会尽可能详细地描述它。

There are 4 strategies base on 4 indicators, custom, and not-custom ones.有基于 4 个指标的 4 种策略,自定义的和非自定义的。 So basically instead of 4 different EAs running in 4 different charts with the same 4 indicators each... The client asked me to optimise them by putting them all in one to run 4 into 1 EAs in the same chart.所以基本上不是 4 个不同的 EA 在 4 个不同的图表中运行,每个图表具有相同的 4 个指标……客户要求我通过将它们全部放在一个中来优化它们,以便在同一个图表中运行 4 到 1 个 EA。

EVERYTHING is the same.一切都是一样的。 They are tested as well that they are the same.它们也经过测试,它们是相同的。 They open the same trades, on the same moments.他们在相同的时刻开启相同的交易。 Nothing is changed 100%.没有什么是 100% 改变的。 The only thing I did (for this part of the debugging, because obviously I had a lot more to do before that) is to copy functions and code.我唯一做的事情(对于这部分调试,因为显然在那之前我还有很多事情要做)就是复制函数和代码。 And I seperated all different strategies with an "if" as input我用“如果”作为输入将所有不同的策略分开

input bool strategy1enabled = true;输入 bool strategy1enabled = true; etc... so he/she can disable/enable individual strategies if wanted.等等......所以他/她可以根据需要禁用/启用个人策略。

everything works BUT.... All but 1 strategies, does not show the Comment on the trades.一切正常,但.... 除了 1 种策略外,其他所有策略均不显示交易评论。

All 4 use the same Buy/Sell/CloseOrder functions so I just input the values to keep the code shorter.所有 4 个都使用相同的 Buy/Sell/CloseOrder 函数,因此我只需输入值以使代码更短。

//---  
bool OrdClose (int ticket_number, double lt, int slp)
  {
      return OrderClose(ticket_number,lt,iClose(NULL,0,0),slp,clrViolet);
  }
//---
int Buy(double lt, int slp, int slss, int tpft, string cmt, int mgc)
  {
      return OrderSend(NULL,OP_BUY,lt,Ask,slp,Ask-slss*Point,Ask+tpft*Point,cmt,mgc,0,clrDarkBlue);
  }
//---
int Sell(double lt, int slp, int slss, int tpft, string cmt, int mgc)
  {
      return OrderSend(NULL,OP_SELL,lt,Bid,slp,Bid+slss*Point,Bid-tpft*Point,cmt,mgc,0,clrDarkRed);
  }

1 strategy just refuses to put comment. 1 策略只是拒绝发表评论。 Any ideas why?任何想法为什么? When used seperated WITH THE SAME CODE and the EXACT SAME functions... comment shows...当使用相同的代码和完全相同的功能分开使用时...评论显示...

EDIT:编辑:

2021.05.04 18:30:48.670 The_Big_Holla_v1_8_EA CADJPY,H1: open #85710545 buy 0.06 CADJPY at 88.755 sl: 88.655 tp: 88.955 ok 2021.05.04 18:30:48.462 The_Big_Holla_v1_8_EA CADJPY,H1: Holla v4.9 || 2021.05.04 18:30:48.670 The_Big_Holla_v1_8_EA CADJPY,H1: open #85710545 在 88.755 sl: 88.655 tp: 88.955 买入 0.06 CADJPY GreedInjectionMode 2021.05.04 18:30:48.462 The_Big_Holla_v1_8_EA CADJPY,H1: Holla v4.9 || GreedInjectionMode 2021.05.04 18:30:48.462 The_Big_Holla_v1_8_EA CADJPY,H1: Holla v4.9 || GreedInjectionMode贪婪注入模式

Comment is passed properly and checked before being passed to function and before OrderSend within function: The function:在传递给 function 和在 function 内的 OrderSend 之前正确传递和检查评论: function:

int Sell(double lt, int slp, int slss, int tpft, string cmt, int mgc)
  {
      Print(cmt);
      return OrderSend(NULL,OP_SELL,lt,Bid,slp,Bid+slss*Point,Bidtpft*Point,cmt,mgc,0,clrDarkRed);
  }

How the function is called: function是如何调用的:

Print(EACommentInj);
ticket_val_inj = Buy(lotsizeInj,slippageInj,stoplossInj,takeprofitInj,EACommentInj,MagicInj);

This is how it is initialised and it NEVER changes.这就是它的初始化方式,它永远不会改变。 It is mentioned only where it is passed.仅在通过的地方提及。 Where I showed you above.我在上面向您展示的地方。

const string EACommentInjGreed = "Holla v4.9 || GreedInjectionMode Greed Mode";

Although this is undocumented, the "string comment=NULL" parameter of the trade function OrderSend() in MQL4 is limited to 31 characters.尽管没有记录,但 MQL4 中交易 function OrderSend()“字符串注释=NULL”参数限制为 31 个字符。 If this limit is exceeded then the string is rejected as a whole and treated as NULL .如果超过此限制,则整个字符串将被拒绝并视为NULL

In your code, just before the OrderSend() function, add the following line:在您的代码中,就在OrderSend() function 之前,添加以下行:

cmt=StringSubstr(cmt,0,31);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM