Unforunately did reversed looping _not_ solve the problem. How do you guys work with positions?
Thank you, Martin
The problem in your code is that you need a separate counter for your array of positions, since not all positions might be valid and added.
Try this:
constint posCount = PositionsTotal();
ArrayResize(pos, 0, posCount); // Initially empty, reserved memory for at most posCount positionsfor (int i = posCount - 1; i >= 0; i--)
{
constulong ticket = PositionGetTicket(i);
if (PositionSelectByTicket(ticket))
{
constint p = ArrayResize(pos, ArraySize(pos) + 1, posCount); // Add one item to the array, p is the new sizeif (p == -1) break;
pos[p - 1].p_symbol = (string)PositionGetString(POSITION_SYMBOL); // Access the last added item
...
}
}
Unforunately did reversed looping _not_ solve the problem. How do you guys work with positions?
Thank you,
Martin
Unforunately did reversed looping _not_ solve the problem. How do you guys work with positions?
Thank you,
Martin
The problem in your code is that you need a separate counter for your array of positions, since not all positions might be valid and added.
Try this:
The problem in your code is that you need a separate counter for your array of positions, since not all positions might be valid and added.
Try this:
Much obliged - will try.