ORDER_POSITION_ID

 

Good afternoon!

Does anyone use

 if ( OrderSelect( ticket ) )
 {
  long pos_id = long( OrderGetInteger( ORDER_POSITION_ID ) );

  if ( pos_id > 0 )
  {
  }
}

Me, when an order is partially executed pos_id always = 0

Why?

From the MQ help:

ORDER_POSITION_ID

The position identifier which is put on the order when it is executed. Each executed order generates a trade, which opens a new position or modifies an existing position. The identifier of this position is set to the executed order at this point.

 
Doesn't anyone know?
 
I use :) as magic when you need to link orders to a position.
 
Yurich:
I use it :) As magic, when it is necessary to link an order to a position.

So why do I have 0?

Because if it had been written in the help it would have said:

Position ID, which is put on the order when it is executed.

Then maybe it should be zero.

But it says:

Each executed order generatesa trade which opens a newposition or modifies an existingposition. The identifier of this position is set to the executed order at that moment.

And a partially executed order also generates a deal.

What do you mean?

 
Mikalas:

So why do I have 0?

It's in servicedesk.

I was answering the question"Does anyone use" and was inaccurate, I useposition ID.

 
Yurich:

It's in servicedesk.

I was answering the question"Does anyone use" and was inaccurate, I useposition ID.

I see, thank you.

But it is the position identifier, but only at the order.

 
Mikalas:

With me, when an order is partially executed pos_id always = 0

Why?

I don't use pos_id, probably because I don't understand what it is for.

I wonder what ID an order should have if it closed a previous position and opened a new one (flip)?

p.s. The idea is that there should only be one civil trading position (no matter which way: buy, sell, hedge). If there seems to be no position, it's temporary).

 
Serj_Che:

I don't use pos_id, probably because I don't understand what it's for.

I wonder what ID an order should have if it closed a previous position and opened a new one (flip)?

p.s. The idea is that there should only be one civil trading position (no matter which way: buy, sell, hedge). If there seems to be no position, it's temporary).

The confusion arises because the reference gives an ambiguous description,

which may be interpreted differently. Because a partly executed order also creates a

Therefore, the order must be assigned an ORDER_POSITION_ID

 
Mikalas:

Good afternoon!

Does anyone use

I always have pos_id = 0 when an order is partially executed.

Why?

Maybe because ORDER_POSITION_ID is requested immediately after the order is executed, when the trade server has not yet had time to send information about the transaction.

Read the article Trade events in MetaTrader 5


 
Rosh:

This may be because ORDER_POSITION_ID is requested immediately after the order is executed, when the trade server has not yet had time to send information about the transaction.

Read the article Trade events in MetaTrader 5


Not sure about your answer?
 
Rosh:

Maybe because ORDER_POSITION_ID is requested immediately after the order is executed, when the trading server has not yet had time to send information about the transaction.

Read article Trade events in MetaTrader 5


It is not clear. If there is a ticket, the transaction is executed, and we have received a response from the server.

What do you mean, we have a ticket, but the server has not received the answer?

Reason: