You could use the IStrategy.onMessage method and set up guards for messages concerning orders closed by SL or TP.
public void onMessage(IMessage message) throws JFException {
if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_TP)) {
// your logic here - it gets triggered as an order gets closed by tp
} else if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_SL)) {
// logic here gets triggered by positions closed for exceeding their SL
} else {
//if the message is about something else
}
}
The above example was taken from the
wiki section with slight modifications, it's usually worth checking out first.