MT5 Trade with Structure is not available

 

It seems new update of MT5 have problem with Trade Structure, I  recive error when compile code. Also my old code not complied.

it is sample code of MQL5 reference but it is not complied , I use Meta trader ,version 5.00 build 2949

#define EXPERT_MAGIC 123456   // MagicNumber of the expert
//+------------------------------------------------------------------+
//| Opening Buy position                                             |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 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   =0.1;                                   // volume of 0.1 lot
   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);
  }
//+------------------------------------------------------------------+
 
Seyed Hadi Ghoreishimedyseh :

It seems new update of MT5 have problem with Trade Structure, I  recive error when compile code. Also my old code not complied.

it is sample code of MQL5 reference but it is not complied , I use Meta trader ,version 5.00 build 2949

Forum on trading, automated trading systems and testing trading strategies

Features of the mql5 language, subtleties and methods of work

Ilyas , 05/20/20/28 18:18

We are expanding the initialization sequences "{...}", in the next build it will be allowed to use any expression, not just a constant one.

Instead of this change, there will be a restriction on the use of constants for enumerations (as for a regular expression): if the constant is not included in the enumeration, an appropriate error will be generated.

Analysis of the existing codes showed that the sequence of one zero - "{0}" is often used incorrectly

For example like this:

 MqlTradeRequest request={ 0 };


Such an entry means setting the value to zero for the first field of the structure and zeroing the rest of the fields.

For the above line of code, according to the new rules, an error will be generated, since the first field is of type ENUM_TRADE_REQUEST_ACTIONS , an enumeration missing the value "0"

cannot convert 0 to enum 'ENUM_TRADE_REQUEST_ACTIONS'


Correctly it will be like this:

 MqlTradeRequest request={};

Reason: