ORDER_POSITION_ID - page 2

 
Need more context (code). Where does this ticket come from, and what does it equal before this code is executed?
 
Rosh:

Maybe this is 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


I gave a snippet of code as an example, but actually the function to get ID looks like this:

//+------------------------------------------------------------------+
//| Get order position ID function                                   |
//+------------------------------------------------------------------+
long GetOrderPosId( const ulong ticket )
{
  long pos_id = 0;
  
  if ( OrderSelect( ticket ) )
  {
    string pos_symbol = OrderGetString( ORDER_SYMBOL );
    
    if ( PositionSelect( pos_symbol ) )
    {
      return( long( OrderGetInteger( ORDER_POSITION_ID ) ) );
    }
  }
  
  return( pos_id );
}

P/S Rosh, please don't send me away to read articles.

Believe me, I've read a lot, and the fact that I'm asking a lot of

Questions, it's because there's a lot of ambiguity in the documentation.

 
marketeer:
We need more context (code). Where does this ticket come from and what does it equal before this code is executed?

If the order is selected, what do you think the ticket was?

And the ticket was taken from the internet as a response to the order being accepted by the trading server.

 
Mikalas:

If the order is selected, what do you think the ticket was?

And the ticket was taken from the internet as a response to the order being accepted by the trading server.

And how do you think we know what and where you are getting it from? You still show code that says nothing about the contents of the ticket, about how the request was executed, and you don't use, for example, debug print or other means to check that the variable doesn't contain a left-handed number (for starters, then request.action equals what?). A bug can creep in anywhere.
 
marketeer:
How do you think we know what you're getting and where it's coming from? You still show code that says nothing about the contents of the ticket, about how the request was executed, and you don't use, for example, debug print or other means to make sure that the variable is not a left-handed number (for starters, then request.action equals what?). A bug can creep in anywhere.
Thank you, I see your point.
 
Mikalas:
Thank you, I understand your point of view.
You're welcome. I don't understand your point. You've already been hinted at the asynchronous execution of the request and receipt of the ticket. Until you show the code how and when you process this stuff, the question turns out to be addressed to telepaths.
 
marketeer:
You're welcome. And I don't understand your point. You've already been hinted at the asynchronous execution of the request and receipt of the ticket. Until you show the code, how and when you process this stuff, the question turns out to be addressed to telepaths.

Let me explain.

From the code above, everything is obvious.

It does not matter which ticket (the order is placed alone). Look carefully (order by ticket and position by order symbol opened partially executed by this order).

In addition to print, there is also a step-by-step execution of the program and

when I get to

return( long( OrderGetInteger( ORDER_POSITION_ID ) ) );

It returns "0".

The question is not if I can or can't program in MQL5 (as well as trace the program), but

The question is if it says one thing in documentation and implement another (service Desk is silent as usual).

Or I may have interpreted correctly description given in documentation onORDER_POSITION_ID

(read my 3 posts).

 
Mikalas:

Let me explain.

From the code above, everything is obvious.

It does not matter which ticket (the order is placed alone). Look carefully (order by ticket and position by order symbol opened partially executed by this order).

In addition to print, there is also a step-by-step execution of the program and

when I get to

It returns "0".

The question is not if I can or can't program in MQL5 (as well as trace the program), but what is in the

The question is if it says one thing in documentation and another thing appears in reality (service Desk is silent as usual).

Or I may have interpreted correctly description given in documentation onORDER_POSITION_ID

(Read my 3 posts).

Again 25. It's IMPORTANT which order and how you place it. Maybe, for example (hypothetically, because everything is still a mystery), you have a pendulum, then what can the position ID be?

The code above doesn't make any sense.

 
marketeer:

25 again. It's IMPORTANT which order and how you place it. Maybe you have, for example (hypothetically, because everything is still a mystery), a pendulum, then what can be the position ID?

The code above doesn't make any sense.

Sorry, but we speak "different" languages, or you read across the line.

The pending order is ONE and the position has been partially opened by thisorder that is still in effect,

When tracing the program, I get toreturn( long( OrderGetInteger( ORDER_POSITION_ID ) ) );

 
Mikalas:

Sorry, but you and I are speaking in "different" languages, or you are reading across the line.

The pending order is ONE and the position has been partially opened by thisorder, which is still in effect,

When tracing the program, I getreturn( long( OrderGetInteger( ORDER_POSITION_ID ) ) );

You observe this partially executed order. Where is it? In the list of trades or in the executed orders?

Reason: