【问题标题】:Sporadic Pending Order function | MQL4零星挂单功能 | MQL4
【发布时间】:2023-02-15 02:19:54
【问题描述】:

所以我有一个 EA,它以当前蜡烛的开盘价放置一个挂单,并在当前蜡烛结束时到期。

我的代码在下面,我什至打印了一个错误函数以诊断可能发生的任何错误,但是,根据 EA,放置了一个挂单,因此不会出现错误。

有时挂单实际上被成功执行,而其他时候,它告诉我挂单已成功下达,但图表上没有出现挂单。

没有错误消息。

很明显没有错误,所以这一定与我的编码有关。我在这里错过了什么?为什么它有时会在图表上放置挂单,而有时又决定不放置?

非常感谢。

if(<Conditions are met>){

   int      pendingExpiration          = Period() * 60;
   double   candleOpenPrice            = iOpen(Symbol(),0,0);
   double   pendingOrderExecPrice      = NormalizeDouble(candleOpenPrice,Digits); 
   
   if(!OrderSend(Symbol(),OP_BUYSTOP,3,pendingOrderExecPrice,100,<sl>,<tp>,0,1,Time[0] + pendingExpiration,0)){
               
         RefreshRates();
         
            Print("Error on pending order "+IntegerToString(GetLastError(),0)); 
         
   }
         
   else {
            
    <confirmaion email function>
         
   }

}

【问题讨论】:

    标签: mql4


    【解决方案1】:

    我唯一看到的是数字的东西:

    你的:NormalizeDouble(candleOpenPrice,Digits);

    我所知道的:NormalizeDouble(candleOpenPrice,_Digits);

    注意下划线。 虽然不确定这是否会导致错误。 您对 candleOpenPrice 的调用有时可能会返回太多(或很少)数字,而这些数字无法通过对 _Digits 的不稳定调用来转换。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-30
      • 1970-01-01
      • 1970-01-01
      • 2022-10-05
      • 2021-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多