Is there a function for an EA that gets triggered when a profit target is hit for a certain position? I can't find one :(
Thanks for helping me out :)
This is one of my functions I use ...
If you tweak the last line of code slightly, you could easily get what you want.
Thanks a lot!
One question remains though: When I select an order via OrderSelect, can i be sure that the position with the highest index is always the last closed order (in case of MODE_HISTORY)? Or do i have to dig through all indices and sort out the latest with OrderCloseTime()?
It is probably best to sort them yourself. There is some anecdotal evidence suggesting the orders are not necessarily always sorted chronologically.
I think it depends on how your broker sorts orders once they are closed, I believe it is chronological
Not always, it would seem:
Anecdotal evidence ? It's documented.
Consecutive selection of orders using the
SELECT_BY_POS parameter returns information in the sequence in which it
was received from the trading server. Sorting of the resulting list of
orders cannot be guaranteed.