Function that returns if the last trade was a win or lose trade

 
I’m looking for a function that returns if the last trade was a win or lose trade. In other words, if the price hit the take profit or the stop loss of the last trade.

If someone decide help me, so, PLEASE, give-me a function that you have sure that work correctly, because I’m not programmer and I have too much difficult with programming… PLEASE…

Thanks a lot!
 
string   LastOrderPL() {
   
   string LastOrderStatus;
   double ProfitandLoss=0.00;

   for(int i=OrdersHistoryTotal()-1;i>=0;i--)
  {
   
   
   if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) &&OrderSymbol()==Symbol()){
     
     if(OrderProfit()>ProfitandLoss){
            LastOrderStatus="Last Order Was in Profit";
            Alert(OrderProfit());
            break;}
            
     else if(OrderProfit()<ProfitandLoss){
     Alert(OrderProfit());
            LastOrderStatus="Last Order Was in Loss";
            break;
     }
   }
    
   }
   return(LastOrderStatus);
   }
   
Code is tested and compiled check that
 
Muhammad Mudasir:
Code is tested and compiled check that

Thanks a lot man!!!!! :) 

Reason: