hini #: I understand the question, but I want to clarify: is it possible to just get a list similar to position history in MT5, without going into details?
I have tried this and it is not the same as the historical positions list in MT5. Even though the two closeby's merged, the volume is still short by 0.01 lots.
That seems incorrect; the direction is incorrect, and the order number doesn't seem to match either.
With CloseBy.
#7217438492025.12.1606:10:25.029 buy 0.03 XAUUSDm 4286.4540.0000.0002025.12.1606:50:54.9424289.8590.000.0010.220#7217438222025.12.1606:13:38.019 sell 0.00 XAUUSDm 4286.3520.0000.0002025.12.1606:50:53.8754286.3520.000.000.00#999167005 by #9991741760#7217438212025.12.1606:10:25.029 buy 0.01 XAUUSDm 4286.4540.0000.0002025.12.1606:50:53.8754286.3520.000.00 -0.10#999167005 by #9991741760
Without CloseBy.
#7217438492025.12.1606:10:25.029 buy 0.03 XAUUSDm 4286.4540.0000.0002025.12.1606:50:54.9424289.8590.000.0010.220: +3405 (+3405) - 00:40:29#7217438212025.12.1606:10:25.029 buy 0.01 XAUUSDm 4286.4540.0000.0002025.12.1606:13:38.0194286.3520.000.00 -0.10#999167005 by #9991741760: -102 (-102) - 00:03:13
In MT5, there are only two entities in the trade history: trades and orders. There are no positions in the trade history and for many years MT5 did not display closed positions.
MQ created this mode of displaying history by generating position history from trade/order history. That's generation. And unfortunately, in some situations it is wrong. In particular, in the above case.
Let's consider the chronology of trading operations in this situation.
The trade 2025.12.16 06:10:25.029 721657655 BUY 0.04 was executed - the position 999167005 BUY 0.04 was opened.
Deals executed 2025.12.16 06:50:54.942 721743849 SELL 0.03 - position 999167005 BUY 0.03 is closed.
In total, exactly three trades were made. And it fully corresponds to what the script shows in the quote above.
In the trade history, OrderTicket is a ticket of the transaction closing the position. Each position has its own OrderTicket. MT4Orders generates the history of positions unambiguously.
The same POSITION_ID (OrderTicketID) value can be used for different positions that did not even overlap in the time of their existence. MT5 generates position history freely.
Take a look at these lines of MT5 position history generation (red is not mine).
There's a lot there that raises questions. In particular, was there a trade turnover (full circle) of 0.05 lots?
Many different trading situations are dealt with in detail on the blog.
Provided all the links with details. Everything works correctly.
I understand the question, but I want to clarify: is it possible to just get a list similar to position history in MT5, without going into details?
Forum on trading, automated trading systems and testing trading strategies
Libraries: MT4Orders
fxsaber, 2025.12.15 11:48 AM
https://www.mql5.com/ru/blogs/post/754817
volume is still not enough for 0.01 lot.
Provide evidence of the error. I recommend to open a demo account on MT4 and try to make the same trading operations there.
is it possible to just get a list similar to the position history in MT5?
Result.
Through snapshots.
This seems wrong; the direction is incorrect and the order number doesn't seem to match either.
Forum on trading, automated trading systems and testing trading strategies
Libraries: MT4Orders
hini, 2025.12.17 02:14 pm.
That seems incorrect; the direction is incorrect, and the order number doesn't seem to match either.
In MT5, there are only two entities in the trade history: trades and orders. There are no positions in the trade history and for many years MT5 did not display closed positions.
MQ created this mode of displaying history by generating position history from trade/order history. That's generation. And unfortunately, in some situations it is wrong. In particular, in the above case.
Let's consider the chronology of trading operations in this situation.
In total, exactly three trades were made. And it fully corresponds to what the script shows in the quote above.
In the trade history, OrderTicket is a ticket of the transaction closing the position. Each position has its own OrderTicket. MT4Orders generates the history of positions unambiguously.
The same POSITION_ID (OrderTicketID) value can be used for different positions that did not even overlap in the time of their existence. MT5 generates position history freely.
Take a look at these lines of MT5 position history generation (red is not mine).
There's a lot there that raises questions. In particular, was there a trade turnover (full circle) of 0.05 lots?
Many different trading situations are dealt with in detail on the blog.
I repeated the experiment and it seems that the historical positions generated by MT5 are correct:
Here I manually opened positions: buy-0.04, sell-0.01, buy-0.04, and then closed all with one button.
And the historical positions generated via CloseBy are different from the one I created manually.
Here are the MT5: historical positions