get buylimit in mql5

 

this is my code for getting buy limit order in mql5, but when the code is compiled, there are 2 errors: 'OP_BUYLIMIT' - undeclared identifier, 'OrderSend' - wrong parameters count

bool result =  OrderSend(
         _Symbol, 
         OP_BUYLIMIT, 
         2*OrdersTotal()*0.01,
         Bid-100*_Point, 3, 
         NULL, 
         NULL, 
         "Buy Limit Order", 
         magicNumber);
 

use Trade.mqh from ..\MQL5\Include\Trade\Trade.mqh

It is faster for beginners.

 
Carl Schreiber #:

use Trade.mqh from ..\MQL5\Include\Trade\Trade.mqh

It is faster for beginners.

i used to mql4, and its ok for me but now, i wana start with mql 5, but getting order is difficult for me , do you have a code for getting pending order? 
 
  1. It's all in the file Trade.mqh
  2. Find an EA in the Codebase a study the way it is done there.
MQL5 Code Base
MQL5 Code Base
  • www.mql5.com
MQL5 Source Code Library for MetaTrader 5
 
Faraz Khatir:this is my code for getting buy limit order in mql5, but when the code is compiled, there are 2 errors: 'OP_BUYLIMIT' - undeclared identifier, 'OrderSend' - wrong parameters count
Faraz Khatir #: i used to mql4, and its ok for me but now, i wana start with mql 5, but getting order is difficult for me , do you have a code for getting pending order? 

OrderSend in MQL5 works completely differently to MQL4.

bool  OrderSend(
   MqlTradeRequest&  request,      // query structure
   MqlTradeResult&   result        // structure of the answer
   );

If you are coming from MQL4 and are having difficulty understanding MQL5 trade functionality, please read the following ...

Articles

Orders, Positions and Deals in MetaTrader 5

MetaQuotes, 2011.02.01 16:13

Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.

Articles

Migrating from MQL4 to MQL5

Sergey Pavlov, 2010.05.17 13:32

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.
Documentation on MQL5: Trade Functions
Documentation on MQL5: Trade Functions
  • www.mql5.com
Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Faraz Khatir #: i used to mql4, and its ok for me but now, i wana start with mql 5, but getting order is difficult for me , do you have a code for getting pending order? 
// gLOBALLY
#include <Trade/Trade.mqh>
CTrade trade;

void OnTick()
{
if(PositionsTotal() == 0) //replace with your condtions

trade.BuyLimit(....); //for all kinds of pending orders

}
 

hi everyone

@Chioma Obunadike

I didn't understand your answer, a Trade.BuyLimit is for placing limit orders waiting to be executed, but how do you retrieve the list of these orders if, for example, the robot restarts?


Best Reguards,
ZeroCafeine 🙂

 
Hoo, I think just a for loops with OrdersTotal() can solve the problem of finding the pending orders, when I will find a complete solution I will come back on this thread 🙂
 

Faraz Khatir

I think this is your answer for the pending orders on this link, For volumes I think you can retrieve order volumes with the function: m_order.VolumeInitial()