Help me, verification of past trades

 
Greetings everyone, I'm new to the language MQL4, and would help to make two checks, if they can help me, how I could do these checks, follows:

checking if the last trade has been lost or not.
check which was the lot of the last volume of trade.

Could someone help me?

Greetings


//+------------------------------------------------------------------+
//| check for losses                                                 |
//+------------------------------------------------------------------+  
bool checkforlosses()                   // we check our last closed order 
{                                       // from losses here 
   int losses=0;                        // total of losses
   int i;                               // pos of our order 
   for(i=0; i<OrdersHistoryTotal(); i++) // looping to check all of our
   {                                     // order history from pos 0 until
                                        // last pos
       OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); // is it right our order?
       if(OrderSymbol()!=Symbol() ||    // if symbol of order didn't match 
       OrderMagicNumber()!=MagicNumber) // with current chart symbol 
       continue;                        // or the magic numb of order 
                                        // didn't match with our magic
                                        // number, it is not our's, just don't check it
       if(OrderProfit()<0) losses++;    // so we count it as a losses 'cause negative profit
       else                losses=0;    // otherwise we leave it as is 
   }
   if(losses>0)  return(true);          // if last of our order is in losses
                                        // true "value" will returned from this function
   return(false);                       // when there is no losses false will returned
}
//+------------------------------------------------------------------+
//| last lot                                                         |
//+------------------------------------------------------------------+ 
double lastlot()                        // we will find last lot size 
{                                       // order with this function
  double lot=0;                         // lot size
  int i;                                // pos of our order 
  for(i=0; i<OrdersHistoryTotal(); i++) // looping to check all of our
   {                                     // order history from pos 0 until
                                        // last pos
       OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); // is it right our order?
       if(OrderSymbol()!=Symbol() ||    // if symbol of order didn't match 
       OrderMagicNumber()!=MagicNumber) // with current chart symbol 
       continue;                        // or the magic numb of order 
                                        // didn't match with our magic
                                        // number, it is not our's
       lot=OrderLots();                 // last lot
  }
  return(lot);                          // last lot size returned
}
 
rafaelr: Could someone help me?

  1. For large amounts of code, attach it
  2. What are Function return values ? How do I use them ? - MQL4 forum
  3. Loops and Closing or Deleting Orders - MQL4 forum
  4. You already posted lastlot(). What is your problem with coding an equivalent using OrderProfit()
 
WHRoeder:

  1. For large amounts of code, attach it
  2. What are Function return values ? How do I use them ? - MQL4 forum
  3. Loops and Closing or Deleting Orders - MQL4 forum
  4. You already posted lastlot(). What is your problem with coding an equivalent using OrderProfit()

When I opened the topic I still do not know this code, but I ended up finding another expert in the code, if someone posted here let also search by subject.

Thank you for your attention.
Reason: