Flag that says a position has been closed

 
Hi

is there a flag or function that determines if a position has been closed by the system taking profit or from stop loss made by the system? Any help is greatly appreciated.

Eric
 
Usually it's enough to compare OrderStop() and OrderClosePrice().
Also can help OrderComment(). See any statement or results of backtesting.