Tâche terminée
Spécifications
first loop
for the last N closed trade (ordered by biggest close time)
Var1 = Var1 + Trade profit
loop end
second loop
for the last N closed trade (ordered by biggest close time) skipping the first X trades (so if x=2 the loop skip the last two closed trade)
Var2 = Var2 + Trade profit
loop end
Else If Var1=Var2 Var3=2
------------
in other words
if in my history there are 10 trades what i need is
with N=5, x=2
loop 1 the sum of profit of the trade 10+9+8+7+6
loop 2 the sum of profit 8+7+6+5+4
the number of trade is ordered from close time not from opening or ticket
-----------------
then i need you to explain me how to retrive Var3 value in my EA after the
Please note
1) that the trade history probably has to be ordered by biggest Close Time because i found From MQL4 Guide link text
"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."
and from link text
"I found that in both 'trade pool' and 'history pool', the list is sorted by time the trade is opened."
"When back testing this seems to work as you might expect with orders entering the list sequentially. When done in live accounts you are better off considering the ordering as random and sorting it yourself."
"By the way, the OrdersHistory also contains balance transfers, identifiable as OrderSymbol()==""
If you have 5 or 6 orders in your history you may be lulled in a false sense of security and think you have the pattern figured out. I just checked it this evening to make sure and of 150 trades in the history there are not just a few out of date order, but lots. The first errors didn't appear until 30 items into the list."
"There is no explicit documentation of the sorting order of this list, so better considering it as random sorted, as Dabbler suggested. It can depend on brokers also.
Perhaps there is a more experienced programmer here, who can point the documentation of this. But, if not, when the sequence of list is critical, you should build a custom array of it, then sort yourself."