Getting the close price of a trade that has SL and TP already set

 

How do I get the close price and close time of a trade after it has hit SL/TP? At entry I do something like this to log the open time information

myTradingControlPanel.PositionOpen(_Symbol,ORDER_TYPE_SELL,lot,currentBid,slPrc,tpPrc, "Sell Trade. Magic Number #" + (string) myTradingControlPanel.RequestMagic());

// Get position time
PositionSelect(_Symbol);
datetime tradeTime = PositionGetInteger(POSITION_TIME);
string tradeTimeString = TimeToString(tradeTime, TIME_DATE|TIME_MINUTES);

I guess I could monitor on every tick whether the last open position is not active (using ticket number? or PositionSelect(_Symbol)==false), but is there an easier way to do this?

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Did you search before posting ?

The site is full of examples and questions about that.

 
Alain Verleyen #: Did you search before posting? The site is full of examples and questions about that.

I didn't find anything related to my specific issue, but I was able to find CHistoryPositionInfo.mqh which does what I want. Thanks. 

Reason: