to use PositionSelectByTicket, you must know ticket number.
your code above is wrong, so ticket = 0.
int total=PositionsTotal(); int count=0; for (int cnt=0; cnt<=total-1; cnt++) { //count++; ulong ticket=PositionGetTicket(count); if(PositionSelectByTicket(ticket)) { //Do something } }
Nguyen Nga:
to use PositionSelectByTicket, you must know ticket number.
your code above is wrong, so ticket = 0.
Yes that's why I used PositionGetTicket & count is the position number.
It it doesn't works in that way, then how should do it? I need to select opened orders.
Below is code. Delete "count++"
int total=PositionsTotal(); int count=0; for (int cnt=0; cnt<=total-1; cnt++) { //count++; ulong ticket=PositionGetTicket(count); if(PositionSelectByTicket(ticket)) { //Do something } }
Nguyen Nga:
Below is code. Delete "count++"
Below is code. Delete "count++"
Hi Thank you its working now.

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,
I have this following code which is not selecting any open position. control is not going inside the "Do something" area.
Please help
Thank you in advance.