n MQL5, the RequestPosition method of the CTrade class returns 0 when the requested position does not exist or when there is no active position that matches the given symbol or parameters. There are several reasons why this might happen:
-
No Active Positions: If there are no positions currently open in the symbol or market you are trying to query, RequestPosition will return 0 .
-
Incorrect Symbol or Ticket: If you're passing an invalid symbol or a ticket number that does not correspond to an active position, the function will return 0 .
-
Position Filtering: If you're filtering positions by parameters like magic number, type, or ticket, and there are no positions matching those filters, the method will return 0 .
-
Permissions/Account Restrictions: Depending on your broker, there might be account settings or permissions that prevent position data from being queried.
I do some backtesting and I can see that my position has been created and therefore exists.
No Active Positions: If there are no positions currently open in the symbol or market you are trying to query, RequestPosition will return 0 .
Incorrect Symbol or Ticket: If you're passing an invalid symbol or a ticket number that does not correspond to an active position, the function will return 0 .
Position Filtering: If you're filtering positions by parameters like magic number, type, or ticket, and there are no positions matching those filters, the method will return 0 .
Permissions/Account Restrictions: Depending on your broker, there might be account settings or permissions that prevent position data from being queried.No Active Positions: I have position for sure, even I have many position, all the time get 0
Would you mind sharing your code? Sometimes, having a fresh set of eyes can help spot something that might be easy to overlook.
Maybe there's a small detail or issue that stands out to someone else, and they could offer some insights or suggestions.
Would you mind sharing your code? Sometimes, having a fresh set of eyes can help spot something that might be easy to overlook.
Maybe there's a small detail or issue that stands out to someone else, and they could offer some insights or suggestions.
yes for sure
if(!Trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, .....) { Do Something } Last_Position_Ticket = Trade.RequestPosition();
Trade.RequestPosition()
tks you Wilna Barnard , Problem solved with RequestPosition method 😊
Trade.RequestPosition()

- 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 everyone,
Do you know why the RequestPosition method of the CTrade class always returns 0 ?
In other words, what is the simplest solution for retrieving the ticket or identifier of the position that has just been opened using my CTrade class?
I thought I saw in the forum a solution to compare the positions with their opening time to recover the last one and therefore the ticket ?
Best Reguards,
ZeroCafeine.