Hi there, in one of my EAs I'm trying to keep a grid with hedged positions and I want to keep two lists with longs and shorts ordered by current profit. Iterating through MT4 pool of orders/trades gives me the orders ordered by creation order, and as far as I know there is no way to get them ordered by profit. At the moment I'm implementing a generic list, but I'm facing two options:
With C++ using the standard library is quite straight forward to sort lists, but I don't want to jump into the complexity of building a DLL for MT4, at least not yet.
Any other suggestion? Thanks in advance.
you can use a two dimensional array, first dimension the order profit and second the ticket number, and use ArraySort() to sort it: https://docs.mql4.com/array/arraysort
Mate you've saved me a lot of work. I'll try it this evening after work but it looks like you hit the nail.
Let me ask another thing in terms of performance. In order to finally have the orders in an array with the correct dimension, which option would you go for?
Thanks in advance!
double A; int n=0;
ArrayResize(A, n+1, 100);
To add comments, please log in or register