ArrayResize(clostab,total); : if(OrderMagicNumber()!=magic || OrderSymbol()!=Symbol() || OrderType()!=clostyp) continue; clostotal++; clostab[clostotal][0] = OrderProfit()+OrderCommission()+OrderSwap();//critére de tri!!! clostab[clostotal][1] = OrderTicket(); clostab[clostotal][2] = OrderLots(); } if(ArraySort(clostab,WHOLE_ARRAY,0,MODE_ASCEND)==false)//Grrrrrrrrrrrrr......
- You resize the array for the maximum (ALL orders)
- You only fill clostotal + 1 to the array. (use nOrders=0; ... clostab[nOrders]...; nOrders=1;)
- You sort ALL the array (use nOrders)
- Result, unfilled elements to the front. Invalid tickets.
Hello WHRoeder
Thanks for your reply.
But...
At the beginning "clostotal = - 1".
Before first use, "clostotal ++", therefore it well started was 0.
Or there is something that escapes me?
I said that the error is not systematic, it is even rare, but well presented.
Hello WHRoeder
Thanks for your reply.
But...
At the beginning "clostotal = - 1".
Before first use, "clostotal ++", therefore it well started was 0.
Or there is something that escapes me?
I said that the error is not systematic, it is even rare, but well presented.
Hello gooly
After careful study of the maps, it seems that the error will occur when there are open at the same time buy and sell orders.
That is to say when total <>clostotal?
And ultimately, the EA recomence a cycle and closes orders without problem.
???
Before first use, "clostotal ++", therefore it well started was 0.
Or there is something that escapes me?
ArraySort(clostab,WHOLE_ARRAY,0,MODE_ASCEND)
You are sorting ALL elements in the array but you only have filled [0 .. clostotal]. Sort only what you HAVE (clostotal+1.)Your variable is clostotal, but it is not a total, it is one less (an index) clostotal =-1; // A total of minus one is meaningless. { clostotal++ clostab[clostotal]=..
I also suggested, you change to self-documenting variable names that mean what it says: nOrders = 0; // Don't have any yet for(...){ clostab[nOrders]=.. // Add one. ++nOrders; // Count it. }
I am...
Thanks for your reply.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Thank you