Can't open a simple buy trade?

 
      MqlTradeRequest myrequest;
      MqlTradeResult myresult;
      ZeroMemory(myrequest);
      ZeroMemory (myresult);
      myrequest.type = ORDER_TYPE_BUY;
      myrequest.action = TRADE_ACTION_DEAL;
      myrequest.sl =0 ;
      myrequest.tp =0 ;
      myrequest.deviation =20;
      myrequest.symbol = _Symbol;
      myrequest.volume = 0.01;
      if(!OrderSend(myrequest,myresult)){
      PrintFormat("OrderSend error %d",GetLastError());}

This is my code for opening a simple buy trade. I wanted to make more complicated stuff since I know how to do it in MQL4, but in MQL5 I can't even make the simplest buy order.

Does anyone know what's stopping the EA from opening a trade?

The error is 4756.

I am using small XM live account for testing, if it matters.

 
Luka Savić:

This is my code for opening a simple buy trade. I wanted to make more complicated stuff since I know how to do it in MQL4, but in MQL5 I can't even make the simplest buy order.

Does anyone know what's stopping the EA from opening a trade?

The error is 4756.

I am using small XM live account for testing, if it matters.

where's the price?
 
Sardion Maranatha:
where's the price?

i tried even with the price, it doesn't work

 

Hi please see here: https://www.mql5.com/en/search#!keyword=4756


Or you can see here

int EXPERT_MAGIC = 12345;   // MagicNumber of the expert
//+------------------------------------------------------------------+
//| Opening Buy position                                             |
//+------------------------------------------------------------------+
void Buy(string symbol,double lots)
  {
//--- declare and initialize the trade request and result of trade request
   MqlTradeRequest request={0};
   MqlTradeResult  result={0};
//--- parameters of request
   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation
   request.symbol   =symbol;                                // symbol
   request.volume   =lots;                                  // volume 
   request.type     =ORDER_TYPE_BUY;                        // order type
   request.price    =SymbolInfoDouble(symbol,SYMBOL_ASK);   // price for opening
   request.deviation=5;                                     // allowed deviation from the price
   request.magic    =EXPERT_MAGIC;                          // MagicNumber of the order
//--- send the request
   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code
//--- information about the operation
   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
  }
//+------------------------------------------------------------------+
 
Marco vd Heijden:

Hi please see here: https://www.mql5.com/en/search#!keyword=4756


Or you can see here

That's what i did later, and it still didn't work. Then i got on my demo mt5 account, and it works there. It seems I can't open trades on a live account with EA?

Does that make sense?

 
Does the account allow experts?
Reason: