I need ticket number

 

Hi

I want to receive that ticket when I open the position.

There is a similar command in MQL4:

Ticket_Number = ordersend(symbol(),OP_BUY,1,Ask,..........);

But , I need this in MQL5

Thank you for your help.

 
Hello please see here.
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Result Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Result Structure
  • www.mql5.com
As result of a trade request, a trade server returns data about the trade request processing result as a special predefined structure of MqlTradeResult type. The code of the error returned by an external trading system. The use and types of these errors depend on the broker and the external trading system, to which trading operations are sent...
 

Marco vd Heijden:
Hello please see here.

hi  Marco  vd Heijden

Thank you,

but I need ticket number of position.

I cant find this.

 

The PositionGetTicket() function does not help me.

I do not need all the tickets number,
I want the ticket number that I just opened position.

There is a similar command in MQL4:

Ticket_Number = ordersend(symbol(),OP_BUY,1,Ask,..........);

 
mansour abc:

The PositionGetTicket() function does not help me.

I do not need all the tickets number,
I want the ticket number that I just opened position.

There is a similar command in MQL4:

Ticket_Number = ordersend(symbol(),OP_BUY,1,Ask,..........);

Trading functions are completely different in MQL5 

When you submit a trade request you must specify the request and the response structure

The response structure has the deal and order ticket numbers.

But you need to read up on trade functions in MQL5 and stop thinking about them in comparison to MQL4 because they are not the same.


https://www.mql5.com/en/docs/trading/ordersend

https://www.mql5.com/en/docs/constants/structures/mqltraderesult

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Result Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Result Structure
  • www.mql5.com
As result of a trade request, a trade server returns data about the trade request processing result as a special predefined structure of MqlTradeResult type. The code of the error returned by an external trading system. The use and types of these errors depend on the broker and the external trading system, to which trading operations are sent...
 
mansour abc :

Hi

I want to receive that ticket when I open the position.

There is a similar command in MQL4:

Ticket_Number = ordersend(symbol(),OP_BUY,1,Ask,..........);

But , I need this in MQL5

Thank you for your help.

What exactly do you want to do? Are you sure that you need a TICKET?

 
mansour abc:

hi  Marco  vd Heijden

Thank you,

but I need ticket number of position.

I cant find this.

Did you visit the link that i posted? 

I can see its there.

Field

Description

retcode

Return code of a trade server

deal

Deal ticket,  if a deal has been performed. It is available for a trade operation of TRADE_ACTION_DEAL type

order

Order ticket, if a ticket has been placed. It is available for a trade operation of TRADE_ACTION_PENDING type


Otherwise you can check here.

ENUM_POSITION_PROPERTY_INTEGER

Identifier

Description

Type

POSITION_TICKET

Position ticket. Unique number assigned to each newly opened position. It usually matches the ticket of an order used to open the position except when the ticket is changed as a result of service operations on the server, for example, when charging swaps with position re-opening. To find an order used to open a position, apply the POSITION_IDENTIFIER property.
 

POSITION_TICKET value corresponds to MqlTradeRequest::position.

long

Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
when attempting to fully or partially close a position if the total volume of the already present close orders and the newly placed one exceeds the current position volume The number of open positions simultaneously present on an account can be limited by the server settings. After a limit is reached, the server returns the...
 
How to start with MQL5
How to start with MQL5
  • 2020.09.17
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 
Thank you all for your help.
Reason: