ORDER_TYPE_BUY and SYMBOL_ASK

 

Hello everyone, I hope you're well 😊.

I'm still a beginner and I see that the PositionOpen function can use different order types,

trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, 1, SymbolInfoDouble(_Symbol, SYMBOL_ASK), 0, 0, "CouCou");

and if I've understood correctly, the ORDER_TYPE_BUY order type means that it's a market order. Do we need to specify a price like SYMBOL_ASK for a market buy?

And how do we know which order type our broker accepts?

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

To open positions there are only two types of market orders, a ORDER_TYPE_BUY, or a ORDER_TYPE_SELL.

A buy order/position opens at the Ask price and a sell opens at the Bid price.

So yes, you should supply the current price (Ask or Bid) according to the order type (Buy or Sell).

 

tks you  Fernando Carreiro

With which function then can we use the other types of orders as shown in the photo?


order type


Or maybe it's something else I'm still missing?

Fernando Carreiro
Fernando Carreiro
  • 2023.04.19
  • www.mql5.com
Trader's profile
 
ZeroCafeine #: tks you  Fernando Carreiro With which function then can we use the other types of orders as shown in the photo? Or maybe it's something else I'm still missing?

Operations with orders

 

OrderOpen

Places a pending order with specified parameters

Also, 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.

 

tks you


It's a wonderful platform, there are so many possibilities, I'm going to take the time to read it all at my leisure and I'll of course get back to you or perhaps ask you more questions,


Thanks again for all your insights 🙂