I found a solution.
The answer is SelectByPositionId(POSITION_IDENTIFIER).
Best Regards
What shall that be? There is no such function, at least not in Build 2755 (last stable).
------
HistorySelectByPosition() is your friend. See documentation for examples.
You just have to loop through all the deals of any position - no matter if the account is hedging or netting, cause there can also be partial closings in a hedging account. If you don´t, you will get wrong results.
Every deal of every positions gives you clear information about the volume and the result of any deal of such a position. You dont have to create a separate table, the table is already provided and it is the deal-history.
On netting accounts sometimes broker opens position by parts, for example you need to open 10 lots, and broker will open deals: 2 lot + 2 lot + 6 lot. In that case to get right open positions number following method can be used:
COrderInfo oi; CPositionInfo p; int getPositionsTotalNetting() { p.Select(_Symbol); long id = p.Identifier(); HistorySelectByPosition(id); int totalOpenPositions= HistoryOrdersTotal(); return totalOpenPositions; }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Partial closes and more opening orders, then close etc.
Thank you