Function to return true if last deal was closed by stop loss

Hello guys!
Im struggling with function which gives true when the latest closed order had been closed by stop loose. Could you help me ?
Thanks in adnvance!!!

bool LastOrderClosedByStop()
   int      ticket      =-1;
   datetime last_time   = 0;
   for(int i=OrdersHistoryTotal()-1;i>=0;i--)
         last_time = OrderCloseTime();
         ticket = OrderTicket();
      Print("OrderSelectError: ",GetLastError())
      return false;
   // credit to whroeder -->
   return fabs(OrderClosePrice()-OrderStopLoss()) < fabs(OrderClosePrice()-OrderTakeProfit());