The new concept of position, orders and deals is too confusing. Need some help!

To add comments, please log in or register
Enrique Molano
50
Enrique Molano  
An order becomes a deal. A long deal open or increases a position. A second long deal increases the position since in MT5 there is only one position per pair.
If I use POSITION_PRICE_OPEN (Position open price) from https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties which open price am getting? The one from the first deal, or the price from the second deal?
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Position Properties - Documentation on MQL5
Samuel Olowoyo
2494
Samuel Olowoyo  
emforex:
An order becomes a deal. A long deal open or increases a position. A second long deal increases the position since in MT5 there is only one position per pair.
If I use POSITION_PRICE_OPEN (Position open price) from https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties which open price am getting? The one from the first deal, or the price from the second deal?

Hello emforex,

If you can really follow it in a very simple manner, you will really understand that it is not actually confusing. Let me try and explain in my own understanding:

When you place a BUY order, once the order is executed it becomes a deal and a position (BUY) is opened. The ORDER_PRICE_OPEN, the DEAL_PRICE and the POSITION_PRICE_OPEN should be the same. Now you decided to place another BUY order, once the order is executed, you have a new deal and this is added to the already opened BUY position (since the order you have just placed is a BUY and in the same direction).

What you have now is a single BUY position with two deals. Two orders have become a part of this single position and now the new TAKE PROFIT (if it is set) will be the take profit of the new order, the same goes for the STOP LOSS (if it is set). However, while the ORDER_PRICE_OPEN, the DEAL_PRICE for this second order will be the same (but different from the first order) the POSITION_PRICE_OPEN has not changed.

To Illustrate this, I have a code that places Buystop/Sellstop pending orders. Now, Two BUYSTOP pending orders were triggered one after the other.

This is the Order Results for this trade

The Buystop order 49 was placed before Buystop order 50, but 50 was triggered before 49. Orders 50 and 49 belongs to a single position which was closed when the stoploss (order 51) set for order 49 was reached at 1.41094. 

This is the deal results for this trade

 

 Deal 47 corresponds to order 50 because it was the first to be trigerred while deal 48 is for order 49. Both deals belong to the same single position which was closed when the stoploss (order 51) which became deal 49 was reached. 

You can see that each order/deal in a single position has their different ticket numbers and the only thing common to them is the POSITION_IDENTIFIER (which is not shown here).

The same explanation goes for the Sellstop order below:

 

 

Here, we have the combination of the orders and deals. Orders 53,52,46 and 42 were all triggered into a single position as deals 50,51,52 and 53 respectively. This single position was closed when the stoploss set for the order 42 was reached. The  POSITION_PRICE_OPEN here is 1.40791, the opening price for this position which consists of 4 orders.

I hope I have been able to answer your question, if not, I believe MetaQuotes will. 

Take care. 

 

okwh
1644
okwh  
 

 Order 49(also deal 48) , Order 50 (also deal 47) combine to a position(no position number)

Order 51(also deal 49) are same, is the postion's SL ( SL is same with one of order ?).

and  Order 49, Order 50 also have different SL ?

right ? 

Enrique Molano
50
Enrique Molano  
DxdCn:

 Order 49(also deal 48) , Order 50 (also deal 47) combine to a position(no position number)

Order 51(also deal 49) are same, is the postion's SL ( SL is same with one of order ?).

and  Order 49, Order 50 also have different SL ?

right ? 

Thanks for the help. It's so different from mql4. When I update the position, the stops affect the position since the order is already a deal/part of the position.
Eric
153
Eric  

 

Are you sure when you say: " ......What you have now is a single BUY position with two deals. Two orders have become a part of this single position and now the new TAKE PROFIT (if it is set) will be the take profit of the new order, the same goes for the STOP LOSS (if it is set). However, while the ORDER_PRICE_OPEN, the DEAL_PRICE for this second order will be the same (but different from the first order) the POSITION_PRICE_OPEN has not changed....."

 I though what you would get as POSITIONGET DOUBLE( POSITION_PRICE_OPEN ) for that would be the average of ORDER_PRICE_OPEN #1 AND ORDER_PRICE_OPEN #2 weighted by the number of lots of each order...

 

 

 

David Diez
1386
David Diez  
Enrique Molano:
An order becomes a deal. A long deal open or increases a position. A second long deal increases the position since in MT5 there is only one position per pair.
If I use POSITION_PRICE_OPEN (Position open price) from https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties which open price am getting? The one from the first deal, or the price from the second deal?

Hi, Enrique, this is how I understand:

A deal is a a set of open orders (positions) from the same symbol in the same direction.

An order could be an open order (position) or a pending order.

To add comments, please log in or register