Download MetaTrader 5

Unknown trade server return code (10027)

To add comments, please log in or register
investeo
4100
investeo  

I cannot place a correct order using my function and the server returns a code not defined in


https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes


2010.02.04 09:38:45    CheckSymbolInfo (EURUSD,H1)    PlaceMarketOrder() return code: 10027

2010.02.04 09:38:45    CheckSymbolInfo (EURUSD,H1)    OrderSend failure.



What does this 100027 code mean and could you help to figure out what is wrong with my code?


bool PlaceMarketOrder(double val)
{
   MqlTradeRequest Request;
        MqlTradeResult Result;
 
        Request.volume = NormalizeDouble(MathAbs(val),2);
   if (val<0)
   {
        Request.type = ORDER_TYPE_SELL; 
        Request.comment = "Sell "+ DoubleToString(Request.volume)+" "+ _Symbol;
   } else
   {
        Request.type = ORDER_TYPE_BUY; 
        Request.comment = "Buy "+ DoubleToString(Request.volume)+" "+ _Symbol;
   }
        Request.action = TRADE_ACTION_DEAL;
        Request.type_filling = ORDER_FILLING_AON;
        Request.price = SymbolInfoDouble(_Symbol, SYMBOL_BID);
        Request.symbol = _Symbol;
        Request.deviation = 5;
        Request.magic = 1;
        Request.sl=0;
        Request.tp=0;

   
   
        bool result = OrderSend(Request, Result); 
        if (result == false)    Print("OrderSend failure.");
        
        Alert("PlaceMarketOrder() return code: " + IntegerToString(Result.retcode));

        

   
   return result;
}

value passed to PlaceMarketOrder is 0.1 or -0.1

Documentation on MQL5: Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes - Documentation on MQL5
investeo
4100
investeo  
Can anyone provide a simple working example of placing an order? Thanks.
Paul
784
Paul  

Does the code you post work for val=-0.1?  This will be an ORDER_TYPE_SELL, which correctly needs the bid price for entry price.

val=0.1 (ORDER_TYPE_BUY) will require

Request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

Also, I think Request.deviation should be set to 50 to allow adequate slippage with a 5 digit broker

Paul

http://paulsfxrandomwalk.blogspot.com/ 

Regularly emailing the status of an account
  • 2012.06.14
  • Paul
  • paulsfxrandomwalk.blogspot.com
Prompted by a query, I thought I'd post a useful little utility that I have used for ages which emails the status of the account every hour.  After lengthy deliberation I decided to call it .... EmailStatus.  With only a small modification it could be used to log the status to a file, and the time...
investeo
4100
investeo  
phampton:

 

Does the code you post work for val=-0.1?  This will be an ORDER_TYPE_SELL, which correctly needs the bid price for entry price.

val=0.1 (ORDER_TYPE_BUY) will require

Also, I think Request.deviation should be set to 50 to allow adequate slippage with a 5 digit broker

Paul

http://paulsfxrandomwalk.blogspot.com/ 

Hi Paul,

Thank you for bid/ask advice. I tried to recompile your FraMa cross EA V1_2 (I only changed LOG to Print) and I get the same error code:

2010.02.08 10:58:05    FraMa cross EA V1_2 (EURUSD,H1)    Problem with OrderSend in AdjustPosition(): Unknown retcode 10027 in RetCodeToStr()

My MT5 build number is 244. Can you confirm this EA works properly on the latest build for you?


Paul
784
Paul  
investeo posted # :

Hi Paul,

Thank you for bid/ask advice. I tried to recompile your FraMa cross EA V1_2 (I only changed LOG to Print) and I get the same error code:

2010.02.08 10:58:05    FraMa cross EA V1_2 (EURUSD,H1)    Problem with OrderSend in AdjustPosition(): Unknown retcode 10027 in RetCodeToStr()

My MT5 build number is 244. Can you confirm this EA works properly on the latest build for you?


Yes, just tried it on build 244 and it successfully issued a buy and sell order in a few minutes on an M1 chart.  I wouldn't write it in quite the same way now, because the behaviour of OrderSend has changed.

Metaquotes seems very quiet about retcode 10027, which isn't listed. 

 Paul

http://paulsfxrandomwalk.blogspot.com/ 

investeo
4100
investeo  

Solved.



was overwritten by




I had first and second option under 'Allow AutoTrading' enabled.

I found the meaning of 10027 by displaying MqlTradeResult.comment


2010.02.08 22:37:53    PlaceOrderTest (EURUSD,M1)    10027 AutoTrading disabled by client


Strange that MetaQuotes remained silent.

To add comments, please log in or register