[SOLVED] How get profit from position ticket in history tab?

 

Hello all. I have a problem in MT5 and mql5

I have this information:

++ Ticket of  position: 131104675

How get of profit this ticket in history tab ???, show image ticket.jpg


HistorySelect(0, INT_MAX);


Please share with me a example ;)

Thanks all.

Thanks for response to me ;)

Thanks for your time.

Files:
ticket.jpg  112 kb
 
The problem is you being lazy. Do your homework, search on the forum and read the documentation.
 

Thanks all, I solved my problem...

My code:

string example(){
   ulong ticket = 131104675; // Ticket search 
   ulong deal_ticket = -1;

   datetime end_date_history = TimeTradeServer(); // Current Time
   datetime start_date_history = end_date_history - 432000; // Decrease 5 day = 432000 seconds
   
   // rage date
   HistorySelect(start_date_history, end_date_history);
   
   // Total deals
   int total_deals = HistoryDealsTotal(); 
   if(total_deals > 0){
      total_deals -= 1;
      
      for(int x = total_deals; x >= 0; x--){
         deal_ticket = HistoryDealGetTicket(x);
         if(deal_ticket > 0 && HistoryDealGetInteger(deal_ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT && HistoryDealGetInteger(deal_ticket, DEAL_POSITION_ID) == ticket){
            if(HistoryOrderSelect(ticket)){
               Print((string)HistoryDealGetDouble(deal_ticket, DEAL_PROFIT));
               /* Here other functions for example 
                  HistoryOrderGetDouble(ticket, ORDER_TP);
               */               
               return "";               
            }else{
               return "-1";
            }  
         }   
      }
      return "-1";  
   }else{
      return "-1";
   }              
}

Bye all ;)