Show Positions in History tab instead of Orders or Deals

 

Hi,

While I am aware of the Orders and the Deals for the history pool, I saw that MT5 on its own interface can also show the trades in the history tab 'summed' as Positions, without all the details from the deals (see pic attached)

Any hint on how to do this, trying to find a way through HistoryOrdersTotal and HistoryDealsTotal is hitting a wall so far, obviously there is no "HistoryPositionsTotal" :-)

Thank you

Files:
 
Report
Report
  • votes: 19
  • 2017.07.19
  • fxsaber
  • www.mql5.com
Библиотека для MetaTrader 4/5, которая позволяет формировать отчеты по истории торгов.
 

I am not sure you understood the question, or you are in the wrong thread

Either way, you're not helping
 
#include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006

void OnStart()
{
  for (int i = OrdersHistoryTotal() - 1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
      OrderPrint();
}

Result:

#764001 2017.09.15 09:37:03 sell 1.00 EURUSD 1.19208 0.00000 0.00000 2017.09.15 09:39:09 1.19206 -7.00 0.00 2.00 0
#1074677 2017.09.15 09:38:51 buy limit 1.00 EURUSD 1.19157 0.00000 0.00000 2017.09.15 09:39:03 1.19209 0.00 0.00 0.00 0 expiration 2017.09.15 09:38:51
#763999 2017.09.15 09:38:29 buy 1.00 EURUSD 1.19203 0.00000 0.00000 2017.09.15 09:38:56 1.19203 -7.00 0.00 0.00 0
#763985 2017.09.15 09:36:53 sell 1.00 NOKJPY 14.055 0.000 0.000 2017.09.15 09:36:55 14.059 -7.00 0.00 -3.62 0
#763968 2017.09.15 09:33:37 sell 1.00 EURUSD 1.19244 0.00000 0.00000 2017.09.15 09:34:12 1.19233 -7.00 0.00 11.00 0
#763906 2017.09.15 09:30:55 sell 1.00 EURUSD 1.19135 0.00000 0.00000 2017.09.15 09:31:09 1.19153 -7.00 0.00 -18.00 0
#763900 2017.09.15 09:28:53 sell 1.00 EURUSD 1.19139 0.00000 0.00000 2017.09.15 09:29:03 1.19139 -7.00 0.00 0.00 0
#763892 2017.09.15 09:28:03 sell 1.00 EURUSD 1.19127 0.00000 0.00000 2017.09.15 09:28:12 1.19144 -7.00 0.00 -17.00 0
#763886 2017.09.15 09:26:52 sell 1.00 EURUSD 1.19108 0.00000 0.00000 2017.09.15 09:27:02 1.19111 -7.00 0.00 -3.00 0
#763884 2017.09.15 08:43:27 buy 1.00 EURUSD 1.19130 0.00000 0.00000 2017.09.15 09:26:41 1.19102 -7.00 0.00 -28.00 0
#763883 2017.09.15 09:26:34 sell 1.00 EURUSD 1.19110 0.00000 0.00000 2017.09.15 09:26:40 1.19105 -7.00 0.00 5.00 0
#763649 2017.09.14 22:41:48 sell 1.00 EURUSD 1.19090 0.00000 0.00000 2017.09.15 08:40:49 1.19144 -7.00 4.97 -54.00 0
#757787 2017.09.14 22:37:57 sell 1.00 EURUSD 1.19075 0.00000 0.00000 2017.09.14 22:38:53 1.19088 -7.00 0.00 -13.00 0
#757779 2017.09.14 22:36:03 sell 1.00 EURUSD 1.19084 0.00000 0.00000 2017.09.14 22:36:34 1.19084 -7.00 0.00 0.00 0
#757764 2017.09.14 22:34:38 sell 1.00 EURUSD 1.19083 0.00000 0.00000 2017.09.14 22:34:51 1.19086 -7.00 0.00 -3.00 0
#751245 2017.09.14 14:14:20 buy 1.00 EURUSD 1.18955 0.00000 1.18956 2017.09.14 14:14:21 1.18955 -7.00 0.00 0.00 [tp 1.18956] 0
#751239 2017.09.14 14:13:58 buy 1.00 EURUSD 1.18976 0.00000 1.18977 2017.09.14 14:14:00 1.18977 -7.00 0.00 1.00 [tp 1.18977] 0
#751203 2017.09.14 14:10:37 buy 1.00 EURUSD 1.18984 0.00000 1.18985 2017.09.14 14:10:38 1.18983 -7.00 0.00 -1.00 [tp 1.18985] 0
#750432 2017.09.14 12:21:22 buy 1.00 EURUSD 1.19006 1.19004 0.00000 2017.09.14 12:21:26 1.19004 -7.00 0.00 -2.00 [sl 1.19004] 0
#750430 2017.09.14 12:21:12 buy 1.00 EURUSD 1.19000 0.00000 1.19000 2017.09.14 12:21:13 1.18997 -7.00 0.00 -3.00 [tp 1.19000] 0
#750090 2017.09.14 11:13:18 buy 1.00 EURUSD 1.18978 0.00000 1.18979 2017.09.14 11:13:25 1.18984 -7.00 0.00 6.00 [tp 1.18979] 0
#750086 2017.09.14 11:12:45 buy 1.00 EURUSD 1.18975 0.00000 1.18976 2017.09.14 11:12:58 1.18978 -7.00 0.00 3.00 [tp 1.18976] 0
#750048 2017.09.14 11:02:52 buy 1.00 EURUSD 1.19019 0.00000 1.19020 2017.09.14 11:02:54 1.19020 -7.00 0.00 1.00 [tp 1.19020] 0
#749975 2017.09.14 10:48:53 buy 1.00 EURUSD 1.18983 0.00000 1.18984 2017.09.14 10:48:54 1.18983 -7.00 0.00 0.00 [tp 1.18984] 0
#749973 2017.09.14 10:48:33 buy 1.00 EURUSD 1.18976 0.00000 1.18977 2017.09.14 10:48:39 1.18981 -7.00 0.00 5.00 [tp 1.18977] 0
#749815 2017.09.14 10:21:27 buy 1.00 EURUSD 1.18887 0.00000 1.18888 2017.09.14 10:21:28 1.18891 -7.00 0.00 4.00 [tp 1.18888] 0
#749792 2017.09.14 10:19:57 buy 1.00 EURUSD 1.18867 0.00000 1.18868 2017.09.14 10:19:59 1.18867 -7.00 0.00 0.00 [tp 1.18868] 0
#749684 2017.09.14 09:36:14 buy 1.00 EURUSD 1.18844 0.00000 1.18838 2017.09.14 09:36:15 1.18840 -7.00 0.00 -4.00 [tp 1.18838] 0
#749679 2017.09.14 09:35:58 buy 1.00 EURUSD 1.18828 0.00000 1.18829 2017.09.14 09:36:00 1.18830 -7.00 0.00 2.00 [tp 1.18829] 0
#749672 2017.09.14 09:33:49 buy 1.00 EURUSD 1.18798 0.00000 1.18797 2017.09.14 09:33:49 1.18796 -7.00 0.00 -2.00 [tp 1.18797] 0
#749659 2017.09.14 09:30:40 buy 1.00 EURUSD 1.18793 0.00000 1.18794 2017.09.14 09:30:42 1.18796 -7.00 0.00 3.00 [tp 1.18794] 0
#749657 2017.09.14 09:30:28 buy 1.00 EURUSD 1.18799 1.18798 0.00000 2017.09.14 09:30:32 1.18797 -7.00 0.00 -2.00 [sl 1.18798] 0
#749648 2017.09.14 09:29:47 buy 1.00 EURUSD 1.18825 1.18823 0.00000 2017.09.14 09:29:49 1.18822 -7.00 0.00 -3.00 [sl 1.18823] 0
#749646 2017.09.14 09:29:31 buy 1.00 EURUSD 1.18821 0.00000 1.18822 2017.09.14 09:29:32 1.18823 -7.00 0.00 2.00 [tp 1.18822] 0
#749640 2017.09.14 09:26:52 buy 1.00 EURUSD 1.18847 0.00000 1.18848 2017.09.14 09:26:54 1.18852 -7.00 0.00 5.00 [tp 1.18848] 0
#749636 2017.09.14 09:25:38 buy 1.00 EURUSD 1.18853 1.18850 0.00000 2017.09.14 09:25:40 1.18847 -7.00 0.00 -6.00 [sl 1.18850] 0
#749632 2017.09.14 09:25:24 buy 1.00 EURUSD 1.18845 1.18844 0.00000 2017.09.14 09:25:27 1.18844 -7.00 0.00 -1.00 [sl 1.18844] 0
#749630 2017.09.14 09:25:18 buy 1.00 EURUSD 1.18846 1.18846 0.00000 2017.09.14 09:25:20 1.18846 -7.00 0.00 0.00 [sl 1.18846] 0
#749626 2017.09.14 09:24:58 buy 1.00 EURUSD 1.18829 1.18827 0.00000 2017.09.14 09:24:59 1.18827 -7.00 0.00 -2.00 [sl 1.18827] 0
#749616 2017.09.14 09:22:20 buy 1.00 EURUSD 1.18827 0.00000 1.18828 2017.09.14 09:22:29 1.18829 -7.00 0.00 2.00 [tp 1.18828] 0
#749581 2017.09.14 09:13:15 buy 1.00 EURUSD 1.18796 1.18793 0.00000 2017.09.14 09:13:17 1.18793 -7.00 0.00 -3.00 [sl 1.18793] 0
#749576 2017.09.14 09:12:03 buy 1.00 EURUSD 1.18799 0.00000 1.18799 2017.09.14 09:12:04 1.18795 -7.00 0.00 -4.00 [tp 1.18799] 0
#749566 2017.09.14 09:11:08 buy 1.00 EURUSD 1.18778 0.00000 1.18777 2017.09.14 09:11:09 1.18779 -7.00 0.00 1.00 [tp 1.18777] 0
#749561 2017.09.14 09:10:48 buy 1.00 EURUSD 1.18767 0.00000 1.18767 2017.09.14 09:10:48 1.18765 -7.00 0.00 -2.00 [tp 1.18767] 0
#749558 2017.09.14 09:10:05 buy 1.00 EURUSD 1.18756 0.00000 1.18757 2017.09.14 09:10:07 1.18757 -7.00 0.00 1.00 [tp 1.18757] 0
#749554 2017.09.14 09:09:51 buy 1.00 EURUSD 1.18746 1.18744 0.00000 2017.09.14 09:09:52 1.18744 -7.00 0.00 -2.00 [sl 1.18744] 0
#749551 2017.09.14 09:09:38 buy 1.00 EURUSD 1.18767 0.00000 1.18764 2017.09.14 09:09:38 1.18760 -7.00 0.00 -7.00 [tp 1.18764] 0
#749549 2017.09.14 09:09:28 buy 1.00 EURUSD 1.18766 0.00000 1.18763 2017.09.14 09:09:28 1.18762 -7.00 0.00 -4.00 [tp 1.18763] 0
#749539 2017.09.14 09:08:11 buy 1.00 EURUSD 1.18766 1.18765 0.00000 2017.09.14 09:08:12 1.18765 -7.00 0.00 -1.00 [sl 1.18765] 0
#749537 2017.09.14 09:08:05 buy 1.00 EURUSD 1.18765 1.18763 0.00000 2017.09.14 09:08:06 1.18764 -7.00 0.00 -1.00 [sl 1.18763] 0
#749535 2017.09.14 09:07:58 buy 1.00 EURUSD 1.18753 1.18752 0.00000 2017.09.14 09:07:58 1.18753 -7.00 0.00 0.00 [sl 1.18752] 0
#749533 2017.09.14 09:07:31 buy 1.00 EURUSD 1.18752 1.18751 0.00000 2017.09.14 09:07:32 1.18749 -7.00 0.00 -3.00 [sl 1.18751] 0
#749530 2017.09.14 09:07:00 buy 1.00 EURUSD 1.18748 1.18745 0.00000 2017.09.14 09:07:02 1.18744 -7.00 0.00 -4.00 [sl 1.18745] 0
#749526 2017.09.14 09:06:13 buy 1.00 EURUSD 1.18743 1.18743 0.00000 2017.09.14 09:06:14 1.18743 -7.00 0.00 0.00 [sl 1.18743] 0
#293721 2017.07.24 11:11:24 balance 0.00  0 0 0 2017.07.24 11:11:24 0 0.00 0.00 5000000.00 Demo deposit 0
 
Yannis:

Hi,

While I am aware of the Orders and the Deals for the history pool, I saw that MT5 on its own interface can also show the trades in the history tab 'summed' as Positions, without all the details from the deals (see pic attached)

Any hint on how to do this, trying to find a way through HistoryOrdersTotal and HistoryDealsTotal is hitting a wall so far, obviously there is no "HistoryPositionsTotal" :-)

Thank you

Check the deals history, each deal has a POSITION_ID (ticket), you then have to sum up the get profit/loss, use the first deal date to have the position open date/time and price, etc...
 
Alain Verleyen:
Check the deals history, each deal has a POSITION_ID (ticket), you then have to sum up the get profit/loss, use the first deal date to have the position open date/time and price, etc...

Thank you, Alain, I totally missed the position_id, now it makes sense. A few gymnastics to do in order to get there, at least I know now how to do it.

Thanks again.

 

ONLY CLOSED DEALS ARE SHOWN AS POSITIONS IN HIST???

 
AL-OTAIBI:

ONLY CLOSED DEALS ARE SHOWN AS POSITIONS IN HIST???

By definition a deal is on history. A deal is not open or close.
Reason: