How can I select this particular trade?
OrderSelect(ticket,SELECT_BY_TICKET); // ticket is from last TradeClose executed;
What if you don't have the last ticket? (e.g. closed via take profit).
then you have to improvise, like:
loop thru history and find ticket with latest closing date,
save ticket number upfront then if trades=0 check that ticket.
save multiple tickets in array then if trades less then array tickets check which trades have closed
by comparing still open tickets against your array.
It all depends on a particular situation but there is a million of ways.
Maybe i can make a nice living writing little cute routines liek that and charging $25 a piece. :)
loop thru history and find ticket with latest closing date,
save ticket number upfront then if trades=0 check that ticket.
save multiple tickets in array then if trades less then array tickets check which trades have closed
by comparing still open tickets against your array.
It all depends on a particular situation but there is a million of ways.
Maybe i can make a nice living writing little cute routines liek that and charging $25 a piece. :)
So the trade order by index is not the closing order?
it doesn't have to be. There is no guarantee that it will.
That would just be too simple right?
![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