- www.mql5.com
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
- www.mql5.com
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?
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 |
- www.mql5.com
We catch the transaction
- 2020.09.17
- www.mql5.com
for anyone who might have this same query in the future. I have dropped the solution here.
ulong open_buy(double lots, string symbol , const double sl = 0, const double tp = 0, const string comment = NULL, const int magic = 678) { MqlTradeRequest request; MqlTradeResult result; MqlTradeCheckResult check; //--- Initialize the trade request ZeroMemory(request); request.action = TRADE_ACTION_DEAL; // Immediate execution request.symbol = symbol; // Current symbol request.volume = lots; // Number of lots request.type = ORDER_TYPE_BUY; // Buy order request.price = SymbolInfoDouble(symbol, SYMBOL_ASK); // Buy price request.deviation = 10; // Price deviation request.magic = magic; // Magic number request.comment = comment; // Order comment //--- Check the request before sending if(!OrderCheck(request, check)) { Print("OrderCheck failed: ", check.comment); } //--- Send the order if(OrderSend(request, result)) { // OrderSend succeeded, result.order contains the ticket number Print("Order opened successfully, ticket: ", result.order); } else { // OrderSend failed Print("OrderSend failed: ", result.retcode); } return result.order; }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.