No it will not. The order in history is not always ordered by close time. Order History sort by closing date - MQL4 forum
PlanandTrade :
thank you that functions from you look good.
thank you that functions from you look good.
Your code is not selecting OrderSymbol() not selecting OrderMagicNumber() and it doesn't even care what OrderType() it selects
Even when the sorting of OrderHistory is correct then also i have to Ask to you
how do you know you get the result you search ??
My answer would be
You Can't !!!!
deVries:
Your code is not selecting OrderSymbol() not selecting OrderMagicNumber() and it doesn't even care what OrderType() it selects
Even when the sorting of OrderHistory is correct then also i have to Ask to you
how do you know you get the result you search ??
My answer would be
You Can't !!!!
that was just a simple example, my original loop looks other. but i did ask because i had not now how the orderhistory structur work.

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
Hello,
i am searching for a code example that can give me the last closed Order profit, wich have beend close with a loose.
I have here a own code example, but i am not sure if this will work always right, for example i dont know if that work when somebody does changes the order history from oldest trades sorting or if he sort in the orderhistory the trades with profit value and so on there are many different ways how somebody can sort hisself the orderhistory and i dont know if my code does work then right.
This is my code: