How to detect the recently closed deal?

Hello to everybody,

My goal is to write an EA which react in a particular way once I close a specified deal; i.e. suppose I have just closed a specified deal by the following code

,
ticket = PositionGetTicket(i);

  print("Opened order ticket no.: "+IntegerToString(ticket)+" closed");

  m_trade.PositionClose(ticket); 

,
where the index ‘i’ refers to the selected openend position

Then I want in my OnTradeTransaction(const MqlTradeTransaction& trans, const MqlTradeRequest& request, const MqlTradeResult& result) detect the deal just closed in order, for example, to detect the gain or the loss.

Advanced thank to everybody will help me.

Hi, what do you want to do after detected profit or loss position? send email? save info to file, journal? for what do you need this info. Regards Greg

My immediate goal is only to detect profit or loss position.

Hi, your statement show you profit and loss position. Regards Greg