Hi,
When you ask for help, please post the code and not a screenshot of it.
Your problem is unclear. You have the magic number to identify your deal, no need for a comment. What result are you expecting and what do you get
effectively ?
Hi,
When you ask for help, please post the code and not a screenshot of it.
Your problem is unclear. You have the magic number to identify your deal, no need for a comment. What result are you expecting and what do you
get effectively ?
Thanks for answering Alain,
Exactly the function does not return the profit value, because the magic number is related to the DEAL_ENTRY_IN which stores the magic number and the comment,
but not the profit which as I showed in the photo is empy, instead the profit is related to the DEAL_ENTRY_OUT but which does not have the magic number or comment
to be able to associate with the starting order.
Anyway I am providing with an internal array, to resolve the problem but if there was a solution I was glad to know that.
here is the code...
double UltimoProfitto(string symbol,int magic) { double UltimoProfitto=0; datetime tempo=0; HistorySelect(0,TimeCurrent()); for(int i=HistoryDealsTotal()-1; i>=0; i--) { ulong deal_ticket=HistoryDealGetTicket(i); string deal_symbol=HistoryDealGetString(deal_ticket,DEAL_SYMBOL); int deal_magic=(int)HistoryDealGetInteger(deal_ticket, DEAL_MAGIC); ENUM_DEAL_ENTRY entry_type = (ENUM_DEAL_ENTRY) HistoryDealGetInteger(deal_ticket, DEAL_ENTRY); int deal_time=(ENUM_DEAL_PROPERTY_INTEGER)HistoryDealGetInteger(deal_ticket,DEAL_TIME); double profit = HistoryDealGetDouble(deal_ticket, DEAL_PROFIT); if(deal_ticket>0 && deal_symbol==symbol && deal_magic==magic && deal_time>tempo) { tempo=(ENUM_DEAL_PROPERTY_INTEGER)HistoryDealGetInteger(deal_ticket,DEAL_TIME); UltimoProfitto= HistoryDealGetDouble(deal_ticket, DEAL_PROFIT); } } return(UltimoProfitto); }
Thanks for answering Alain,
Exactly the function does not return the profit value, because the magic number is related to the DEAL_ENTRY_IN which stores the magic number and the comment,
but not the profit which as I showed in the photo is empy, instead the profit is related to the DEAL_ENTRY_OUT but which does not have the magic number or comment
to be able to associate with the starting order.
Anyway I am providing with an internal array, to resolve the problem but if there was a solution I was glad to know that.
here is the code...
when placing an order with CTrade class use this line:
m_trade.SetExpertMagicNumber(magic);
see here : https://www.mql5.com/en/forum/328698
- 2019.12.18
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I can not identify and therefore distinguish the last profit of a series of orders in the historical one neither from the magic number nor from the comment on mql5.
I can only get the last profit and the last magic number or comment of the last order, but I cannot identify the last profit of a series of orders distinguished by magic number or comment.
I see that in the history orders the deal has no comment in order to be able to identify it to which starting order it belongs.
Has anyone a solution to this problem of mine?
Here is the function i am using:
and the history orders example where there is no comment or magic number to refer to the deal profit:
Another problem is that Orders ticket number are different than the Deals ticket number..