OrderModify error 4027

To add comments, please log in or register
lchellini
100
lchellini  

Hi everyone.

I'm developing an EA and sometimes I get an error 4027 ("too many formatters in the format  function") when I try to modify the order SL.

The error does not always occur: sometimes it works, sometimes it doesn't and I don't understand the problem.

Here is the code I use:

ResetLastError();
if( OrderSelect(p_ticketID, SELECT_BY_TICKET) ){
   if( OrderStopLoss() == p_newSL ){
      return;
   }
   if( OrderType() == 0 && OrderStopLoss() > p_newSL ){
      return;
   }
   if( OrderType() == 1 && OrderStopLoss() < p_newSL ){
      return;
   }      
   color orderColor = OrderType() == OP_BUY ? clrGreen : clrRed;
   bool result = OrderModify(p_ticketID, OrderOpenPrice(), p_newSL, OrderTakeProfit(), 0, orderColor);

   int err = GetLastError();
   if( err != ERR_NO_ERROR ){
      Print("Modify SL Error = ", ErrorDescription(err));
   }
}


Thanks for your help

Lorenzo

lippmaje
810
lippmaje  

It's a strange error code considering the fact that you reset last error beforehand. Could you check the result variable, too:

bool result = OrderModify(p_ticketID, OrderOpenPrice(), p_newSL, OrderTakeProfit(), 0, orderColor);
if(!result)
 {
    int err = GetLastError();
    Print("Modify SL Error = ", ErrorDescription(err));
 }
William Roeder
19170
William Roeder  
Don't look at GLE unless you have an error.
lchellini
100
lchellini  
Solved!


The value p_newSL  is passed as a parameter to this function and the error is generated by normalizeDouble called on p_newSL before this function

Thanks!

To add comments, please log in or register