Download MetaTrader 5
To add comments, please log in or register
Are you used to trading from your smartphone? Mobile version of MetaTrader 5 will suit you best!
johnnybegoode77
43
johnnybegoode77 2016.02.12 11:24 

How do I rewrite these from mql4 to mql5?

1) asking1 = MarketInfo("GBPUSD",MODE_ASK);

2) int ticket=OrderSend("EURUSD",OP_BUY,Lots,Ask,3,0,0,"My EA",12345,0,Green);

Alain Verleyen
Moderator
30295
Alain Verleyen 2016.02.12 12:18  
Migrating from MQL4 to MQL5
Migrating from MQL4 to MQL5
  • 2010.05.17
  • Sergey Pavlov
  • www.mql5.com
This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.
johnnybegoode77
43
johnnybegoode77 2016.02.13 07:22  
Alain Verleyen:
See these articles : Orders, Positions and Deals in MetaTrader 5


//********************************************  Emulation *******************************************

//--- Declaration of constants
#define OP_BUY 0           //Buy
#define OP_SELL 1          //Sell
#define OP_BUYLIMIT 2      //Pending order of BUY LIMIT type
#define OP_SELLLIMIT 3     //Pending order of SELL LIMIT type
#define OP_BUYSTOP 4       //Pending order of BUY STOP type
#define OP_SELLSTOP 5      //Pending order of SELL STOP type


Still get

Error: 'OrderSend' - wrong parameters count  

for

int ticket=OrderSend("EURUSD",OP_BUY,Lots,Ask,3,0,0,"My EA",12345,0,Green);


What did I missed in the Emulation?

Dimitr Trifonov
756
Dimitr Trifonov 2016.02.13 10:26  

Please check https://www.mql5.com/en/docs/trading/ordersend

There's an example of opening a random pending order using OrderSend(), as you see the structure of 'mql5 OrderSend()' is not the same as 'mql4 OrderSend()'

//+------------------------------------------------------------------+ 
//| Sets a pending order in a random way                             | 
//+------------------------------------------------------------------+ 
uint SendRandomPendingOrder(long const magic_number) 
  { 
//--- prepare a request 
   MqlTradeRequest request={0}; 
   request.action=TRADE_ACTION_PENDING;         // setting a pending order 
   request.magic=magic_number;                  // ORDER_MAGIC 
   request.symbol=_Symbol;                      // symbol 
   request.volume=0.1;                          // volume in 0.1 lots 
   request.sl=0;                                // Stop Loss is not specified 
   request.tp=0;                                // Take Profit is not specified      
//--- form the order type 
   request.type=GetRandomType();                // order type 
//--- form the price for the pending order 
   request.price=GetRandomPrice(request.type);  // open price 
//--- send a trade request 
   MqlTradeResult result={0}; 
   OrderSend(request,result); 
//--- write the server reply to log   
   Print(__FUNCTION__,":",result.comment); 
   if(result.retcode==10016) Print(result.bid,result.ask,result.price); 
//--- return code of the trade server reply 
   return result.retcode; 
  } 
Documentation on MQL5: Trade Functions / OrderSend
Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
Trade Functions / OrderSend - Reference on algorithmic/automated trading language for MetaTrader 5
johnnybegoode77
43
johnnybegoode77 2016.02.14 00:16  
Dimitr Trifonov:

Please check https://www.mql5.com/en/docs/trading/ordersend

There's an example of opening a random pending order using OrderSend(), as you see the structure of 'mql5 OrderSend()' is not the same as 'mql4 OrderSend()'

how do i rewrite

int ticket=OrderSend("EURUSD",OP_BUY,Lots,Ask,3,0,0,"My EA",12345,0,Green);

in mql5?

johnnybegoode77
43
johnnybegoode77 2016.02.14 23:05  
johnnybegoode77:

how do i rewrite

int ticket=OrderSend("EURUSD",OP_BUY,Lots,Ask,3,0,0,"My EA",12345,0,Green);

in mql5?



Do you have a universal emulation scripts?

(Those that could cut and paste?)

Thank you!

Alain Verleyen
Moderator
30295
Alain Verleyen 2016.02.16 08:54  
Please do not double post. Thanks.
/
To add comments, please log in or register