Total Current Profit

 

Hi,

I know how to get the profit of a position on the current symbol the EA is running on. But how to get the total profit for all the position opened by the EA ?


Thanks.


EDIT : Is there anyway to get notification only for answers received on the forum ?

 
blouf:

Hi,

I know how to get the profit of a position on the current symbol the EA is running on. But how to get the total profit for all the position opened by the EA ?


Thanks.


EDIT : Is there anyway to get notification only for answers received on the forum ?

Hello blouf, if you want to receive a "notification" for the current topic, an option would be to mark it as favorite (select the yellow star at the right side of the topic name). Once any answer is added to the topic a yellow star will apear at the upper part of the MQL5.com website after you've logged in.

Regarding your question, an approach to compute the total EA profit (as a function of the EA Magic Number) would be:

double total_EA_profit(long _EA_Magic)
  {
   datetime start   = 0;
   datetime end     = TimeCurrent();
   HistorySelect(start,end);
   int deals_total = HistoryDealsTotal();
   double deal_result = 0;
   double cum_result = 0;
   for(int i=0;i<deals_total;i++)
     {
      if(HistoryDealGetInteger(HistoryDealGetTicket(HistoryDealsTotal()-i),DEAL_MAGIC)==_EA_Magic)
        {
         if(HistoryDealGetInteger(HistoryDealGetTicket(HistoryDealsTotal()-i),DEAL_ENTRY)==DEAL_ENTRY_OUT || HistoryDealGetInteger(HistoryDealGetTicket(HistoryDealsTotal()-i),DEAL_ENTRY)==DEAL_ENTRY_INOUT)
           {
            deal_result = HistoryDealGetDouble(HistoryDealGetTicket(HistoryDealsTotal()-i),DEAL_PROFIT);
            cum_result += deal_result;
           }
        }
     };
   return cum_result;
  };
 
Malacarne:

Hello blouf, if you want to receive a "notification" for the current topic, an option would be to mark it as favorite (select the yellow star at the right side of the topic name). Once any answer is added to the topic a yellow star will apear at the upper part of the MQL5.com website after you've logged in.

Regarding your question, an approach to compute the total EA profit (as a function of the EA Magic Number) would be:

Thanks very much. I'll give a try. I believed the magic number was only for MT4 EA
 

Add per profit,what is total profit.

code like,

for(...)

    profittotal+=profit; 

Reason: