You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thanks, but that's how it's done.
Thanks, but that's how it's done.
:) well sometimes a little creativity can buck the standard procedures :). Although this is not as efficient as what nicholi provided... it does the job!
You have at your disposal essemtial variables startDateTime,endDateTime, and _magic
In order to associate the deal_position_id's to a corresponding Magic Number... we take a little detour and gather a string list (comma separated) of all the deal_positions_IDs that are associated with the magic number.hec you can even associates part of the order_comments as well and produce the position_ids that YOU need that way to.
So what is it then? Since we are interested in the "in" and "out" deals and as you loop thru the DealsHistory you can see that they pop up as the index is increments plus you know you can identify the "in"/"out" deals with the deal_entry_type.
Well then lets create a very simple array (in[]) of type struct. The struct array will contain 3 props: deal_position_id, deal_type,deal_price. So since the "in" deals are returned as we step thru the index first tell the script that when deal_entry_type=DEAL_ENTRY_IN to populate the in[] Array structure with the 3 items we need. Now later on the "out" deals start to appear and since we know that those positions_IDs need to match the "in" deals and we already have that in an array in[], well then we just program the script for when deal_entry_type=DEAL_ENTRY_IN to loop thru the already populated in[] array and whenever we see that the in.position_id=out_position_id ... we do the subtraction and get the pips etc etc etc.
Oh and since I kinda still like that old MT4 MarketInfo() function I am including the include code below as well. That allows ya to use the function in MT5 just as it you were in MT4 LOL
Anyhow... see the code... figure it out... and enjoy!
Enjoy!!!!!
zee mt4Functions.mqh: