Retcode 10014 for close orders

To add comments, please log in or register
md42
77
md42  

Hi,

I am stuck with an error Retcode 10014 that happened once and i can't replicate again.

That error appeared on closing an order. 

Error Message : 

Error message

I understand that the problem is on volume but if the system manage to open such as that 
order with this volume why cannot close it with the same volume. 

In the code below is the function that close orders. As you see, it get the volume of the Position 
to close the trade. 

Code : 

for (int i=PositionsTotal()-1; i >=0; i--)
        {
           ulong ticket_temp = PositionGetTicket(i);
                if (ticket_temp > 0)
                {
                   ulong magic_temp = PositionGetInteger(POSITION_MAGIC);
                   string symbol_temp = PositionGetString(POSITION_SYMBOL);
                   if(magic_temp != magicNum_parameter || symbol_temp != symbol_parameter)continue;
                   MqlTradeRequest request={0}; 
                   MqlTradeResult result={0};
                   ENUM_POSITION_TYPE type_temp = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
                        request.action   = TRADE_ACTION_DEAL;        
         request.position = ticket_temp;          
         request.symbol   = symbol_temp;
         request.volume   = PositionGetDouble(POSITION_VOLUME);    <------------------- // Here is the Volume of the position                
         request.deviation= 5;                       
         request.magic    = magic_temp;
         request.type_filling = FillingOrder(symbol_parameter); 
         MqlTick tick;
         SymbolInfoTick(symbol_parameter,tick);             
         if(type_temp == POSITION_TYPE_BUY)
           {
            request.price = tick.bid;
            request.type  = ORDER_TYPE_SELL;
           }
         else
           {
            request.price = tick.ask;
            request.type  = ORDER_TYPE_BUY;
           }
                   if(!OrderSend(request,result)){
                                int error_temp = GetLastError(); 
                                Print("The Active Order WAS NOT Closed --- Ticket = "+(string)ticket_temp+" --- (Function = "+(__FUNCTION__)+") --- ERROR("+(string)error_temp+ ") = "+ErrorDescription(error_temp));
                                Print("Retcode("+(string)result.retcode+ ") = "+RetcodeDescription(result.retcode));
            Sleep(1000);
            i++;
            ResetLastError();
                        }                       
                }else{
                   int error_temp = GetLastError();
         Print("The Active Order WAS NOT Selected --- (Function = "+(__FUNCTION__)+") --- ERROR("+(string)error_temp+ ") = "+ErrorDescription(error_temp));
         check_temp =false;
         ResetLastError();
      }
        }


I am using this code in many EAs just fine.

Any ideas i will appreciate!

Thank you! 

Carl Schreiber
Moderator
8500
Carl Schreiber  

It could be that your broker has some unorthodox volumes, or that the position already has been closed, ...

If you can't replicate it you'd better change the Printout of:

Print("Retcode("+(string)result.retcode+ ") = "+RetcodeDescription(result.retcode));

so that all parameters of the OrderSend(..) function are printed and maybe you can print even the results of OrderCheck()?

md42
77
md42  
Carl Schreiber:

It could be that your broker has some unorthodox volumes, or that the position already has been closed, ...

If you can't replicate it you'd better change the Printout of:

so that all parameters of the OrderSend(..) function are printed and maybe you can print even the results of OrderCheck()?


Thank you for the reply.

Actually the error occur not on real broker but on mql5 admin tests before publishing a product. 
And they are not trying to be helpful in any way..

Also If the order was closed then the PositionGetTicket  wouldn't return a valid ticket.

Thank you!

To add comments, please log in or register