Expert advisor works with build 527 but not with 540

 

Hi all,

  a strange thing: I have an expert advisor which works fine in MetaTrader 5.00 build 527 but it doesn't work in build 540 (same machine).

  I have double checked that I test with the same code. In Build 540 I get the following error:

2011.11.14 18:26:18 Core 1 2010.01.26 16:06:28   failed instant buy 0.10 EURUSD at 1.40622 [Invalid request]

  GetLastError() returns 4756 (Trade request sending failed) and MqlTradeResult of OrderSent returns 10013 (Invalid request).

TIf I try one of the sample Experts installed by default they seem to work.

 

  Now that would mean that there is some error in my strategy which I naturally accept. What I do not understand is why the same code works in MT5 build 527 and not 540. 

  I try opening my positions by calling this function:

void LongPositionOpen()
  {
   MqlTradeRequest mrequest;                             // Will be used for trade requests
   MqlTradeResult mresult;                               // Will be used for results of trade requests
   double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);    // Ask price
   double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);    // Bid price

   if(!PositionSelect(_Symbol))
     {
      mrequest.action = TRADE_ACTION_DEAL;               // Immediate order execution
      mrequest.price = NormalizeDouble(Ask,_Digits);     // Lastest Ask price
      mrequest.sl = 0;                                   // Stop Loss
      mrequest.tp = 0;                                   // Take Profit
      mrequest.symbol = _Symbol;                         // Symbol
      mrequest.volume = Lot;                             // Number of lots to trade
      mrequest.magic = 0;                                // Magic Number
      mrequest.type = ORDER_TYPE_BUY;                    // Buy Order
      mrequest.type_filling = ORDER_FILLING_FOK;         // Order execution type
      mrequest.deviation=5;                              // Deviation from current price
      OrderSend(mrequest,mresult);                       // Send order
     }
     Alert(GetLastError());
     Alert("ret", mresult.retcode);
  }

   Any ideas?

 

Best regards

 

Huckey 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure of a Trade Request Result
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Structure of a Trade Request Result - Documentation on MQL5
 

Hey, i have the same problem with my EA's. Before the update i had no problems with backtesting.

But know i get the same error "2011.11.14 21:56:12    Core 1    2010.06.03 10:21:00   failed instant buy 1.00 EURUSD at 1.23138 [Invalid request]".


What's happend?


Thanks for help.

 

I also report the same problem with my EA when using Build 540: "failed instant buy ........ [Invalid Request]".  What changed in this build?

Thanx 

 

Hi All, 

Have you tested to configure all the parameter of your order?

Ex: 

mrequest.expiration=0;

mrequest.type_time=ORDER_TIME_GTC;

ect...

 good luck 

 

Try to modify your code like this

   MqlTradeRequest mrequest;                             // Will be used for trade requests
   MqlTradeResult mresult;                               // Will be used for results of trade requests
   ZeroMemory(mrequest);
   ZeroMemory(mresult);

 

 

Same problem with build 540 but ZeroMemory helps.
 
alexvd:

Try to modify your code like this

 

Great, thanks, it works!

 

Best regards

 

Huckey 

 

  hi Alex I add zeromemroy and  it works .thnx
void SellOrder(string sym,int magi,double l)
{
    
  
   
    //--- prepare a request
     MqlTradeRequest request;
      MqlTradeResult result;
      
    ZeroMemory(request);
   ZeroMemory(result);
    request.action = TRADE_ACTION_DEAL;          // setting a deal order
    request.magic = magi;                   // ORDER_MAGIC
    request.symbol = sym;                   // symbol
    request.volume = l;                      // volume in lots
    request.price = Bid(sym);
    request.sl = 0;      // Stop Loss specified
    request.tp = 0;    // Take Profit specified
    request.deviation = 4;             // deviation in points
    request.type = ORDER_TYPE_SELL;
    request.comment = TimeToString(TimeCurrent(),TIME_MINUTES);
    
   
    OrderSend(request,result);
    // check the result
    if (!IsError(result, __FUNCTION__))
    {
            
    }
}

  

 

 
i have the same problem,what did they change in version 540?
Reason: