Your topic has been moved to the section: Expert Advisors and Automated Trading — Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Eugen Funk:
Hi,
recently I observed the issue that the MQL method PositionGetTicket() failed. It returned 0 for many, many trials.
If this error comes up I still can place orders. But it would be interesting for me to know what a reason might be. Broker error, broker blocks something, merket closed, delay...?
Thank you very much for your ideas
It may be an error from the code itself.
I have not looked at your code: did you use it in a loop? Do you know ticket is ulong type of integer? Example below...(how i do it):
int Total=PositionsTotal(); for(int i=0; i<Total; i++){ ulong ticket=PositionGetTicket(i); //This should loop through all the positions and then you can get several parameters of the Positions eg string Symb= PositionGetString(POSITION_SYMBOL); }
Busingye Tusasirwe #:
It may be an error from the code itself.
I have not looked at your code: did you use it in a loop? Do you know ticket is ulong type of integer? Example below...(how i do it):
The main suggestion on positions is to go backwards, never iterate forward.
Reasons are given on multiple threads on this forum. Do a search, please.
Your version is inconsistent at the moment.
Edit:
for(int i=Total - 1; i>=0; i--)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
recently I observed the issue that the MQL method PositionGetTicket() failed. It returned 0 for many, many trials.
If this error comes up I still can place orders. But it would be interesting for me to know what a reason might be. Broker error, broker blocks something, merket closed, delay...?
Thank you very much for your ideas