为什么 OrderModify() returns 代码错误 130?

Why OrderModify() returns a code-error 130?

我的公开市场订单有一个订单修改代码,它在 MT4 期刊中出现 Error 130,我知道这是一个时代-老问题&我已经看过几个来源,包括这里和整个网络-但是,似乎没有任何效果。

1) 我已经 NormalizeDouble()-治愈了所有在 MQL4 上具有双重功能的东西,即价格等 - 这是为了确保位数小数点后与其交易的货币对一致;有的是3位数,有的是5位数。

2) pnlPoints&stopPoints是用_Period计算出来的所以无论点数多少,点数都是一致的EA 所在的图表小数点后的数字

3) 我知道 MarketInfo( Symbol(), MODE_STOPLEVEL ) 的存在并且已将其添加到 MarketInfo( Symbol(), MODE_SPREAD )stoplevel 计算。

4) 我要100点"In the money"才修改订单为盈亏平衡

5) 我使用的是五位数经纪商,但如您所知,某些货币对(例如 EURJPY 将具有三位数。 _PeriodNormalizeDouble() 函数对此进行了纠正。

                 /*Breakeven Order Modification*/
                 for(int b = OrdersTotal()-1;b>=0;b--)
                 {
                 if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)==true)
                    {
                    double   aBidPrice   =  MarketInfo(Symbol(),MODE_BID);
                    double   anOpenPrice =  OrderOpenPrice();
                    double   aNewTpPrice =  OrderTakeProfit();
                    double   aCurrentSL  =  OrderStopLoss();
                    double   aNewSLPrice =  anOpenPrice;
                    double   pnlPoints   =  NormalizeDouble(aBidPrice - anOpenPrice/_Point,Digits);
                    double   stopPoints  =  NormalizeDouble(aBidPrice - aNewSLPrice/_Point,Digits);
                    int      stopLevel   =  int(MarketInfo(Symbol(),MODE_STOPLEVEL)+MarketInfo(Symbol(),MODE_SPREAD));
                    int      aTicket     =  OrderTicket();
                    if(OrderType() == OP_BUY)
                    if(stopPoints > stopLevel)
                    if(aTicket > 0)
                    if(pnlPoints > breakeven)
                    if(aNewSLPrice == aCurrentSL)continue;
                       {
                       BuyMod = OrderModify(OrderTicket(),NormalizeDouble(anOpenPrice,Digits),NormalizeDouble(aNewSLPrice,Digits),NormalizeDouble(aNewTpPrice,Digits),0,buycolor);
                       SendMail("Notification of Order Modification for Ticket#"+IntegerToString(OrderTicket(),10),"Good news! Order Ticket#"+IntegerToString(OrderTicket(),10)+"has been changed to breakeven");
                       if(BuyMod = false || aTicket == 0)
                          {
                          Print("Order modification for ticket #"+IntegerToString(aTicket,10)+"Error code",GetLastError());
                          }
                       }
                    }
                 }
                 for(int s = OrdersTotal()-1; s>=0; s--)
                    {
                    if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES)==true)
                       {
                       double   anAskPrice  =  MarketInfo(Symbol(),MODE_ASK);
                       double   anOpenPrice =  OrderOpenPrice();
                       double   aNewTpPrice =  OrderTakeProfit();
                       double   aCurrentSL  =  OrderStopLoss();
                       double   aNewSLPrice =  anOpenPrice;
                       double   pnlPoints   =  NormalizeDouble(anOpenPrice - anAskPrice/_Point,Digits);
                       double   stopPoints  =  NormalizeDouble(aNewSLPrice - anAskPrice/_Point,Digits);
                       int      stopLevel   =  int(MarketInfo(Symbol(),MODE_STOPLEVEL)+MarketInfo(Symbol(),MODE_SPREAD));
                       int      aTicket     =  OrderTicket();
                       if(OrderType()== OP_SELL)
                       if(stopPoints > stopLevel)
                       if(aTicket > 0)
                       if(pnlPoints > breakeven)
                       if(aNewSLPrice == aCurrentSL)continue;
                          {
                          SellMod = OrderModify(OrderTicket(),NormalizeDouble(anOpenPrice,Digits),NormalizeDouble(aNewSLPrice,Digits),NormalizeDouble(aNewTpPrice,Digits),0,sellcolor);
                          SendMail("Notification of Order Modification for Ticket#"+IntegerToString(OrderTicket(),10),"Good news! Order Ticket#"+IntegerToString(OrderTicket(),10)+"has been changed to breakeven");
                          if(SellMod = false || aTicket == 0)
                             {
                             Print("Order modification for ticket #"+IntegerToString(aTicket,10)+"Error code",GetLastError());
                             }
                          }
                       }
                    }

非常感谢和问候。

MQL4错误130代表ERR_INVALID_STOPS

因此,下一个最佳步骤是检查您的 OrderModify() 调用,添加实际值的自我记录,这些值将被放入服务器端发送的指令中。

设计一个包装函数,具有与标准 OrderModify() 完全相同的调用签名:

int LogAndSendOrderModify( int      const aTicketNUMBER,
                           double   const anOrderOpenPRICE,
                           double   const aStopLossPRICE,
                           double   const aTakeProfitPRICE,
                           datetime const anExpirationTIME,
                           color    const aMarkerArrowCOLOR
                           ){ ... }

... 并在 OrderModify() 之前包含一段代码,它准确地将每个值记录到日志中。

PrintFormat( "[%s]: TKT:[%d]OP:[%15.8f]SL:[%15.8f]TP:[%15.8f]SL_STOPZONE:[%d]TP_STOPZONE:[%d]SL_FREEZEZONE:[T.B.D.]TP_FREEZEZONE:[T.B.D.]",
              __FUNCTION__,
              aTicketNUMBER,
              anOrderOpenPRICE,
              aStopLossPRICE,
              aTakeProfitPRICE,
              (int) ( MathPow( 10, _Digits ) * ( Bid - aStopLossPRICE ) ),
              (int) ( MathPow( 10, _Digits ) * ( aTakeProfitPRICE - Bid ) )
              );

对于 ??_FREEZEZONE 您需要提供类似的值,但需要相应地调用 OrderSelect( aTicketNUMBER, ... ),然后再向当前状态发出任何请求db.Pool 条记录中有 { OrderTakeProfit() | OrderStopLoss() },但原理很明显。

事实很重要,如果自我报告的价值符合经纪人条款和条件并且仍然不断收到 ERR_INVALID_STOPS请向您的经纪人索要应得的费用解释观察到的任何不合规情况。