second highest sell order and second lowest buy order

 

I am trying to find the 2nd highest sell and 2nd lowest buy

What is actually wrong with my comparison for populate the 2nd highest and 2nd lowest?

double Highest2ndSell()
{
   double highest2nd=0,highest=0;
   for(int i=OrdersTotal()-1; i>=0; i--) //
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderType()==OP_SELL && OrderSymbol()==Symbol())
         highest=MathMax(highest, OrderOpenPrice());
         highest2nd=MathMin(highest, OrderOpenPrice());
   }
   return(highest2nd);
}
double Lowest2ndBuy()
{
   double lowest2nd=999999999,lowest=999999999;
   for(int i=0; i<OrdersTotal();i++) //
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderType()==OP_BUY && OrderSymbol()==Symbol())
         lowest=MathMin(lowest, OrderOpenPrice());
         lowest2nd=MathMax(lowest, OrderOpenPrice());
   }
   return(lowest2nd);
}
 
  1. Don't double post! You already had another thread open.

              General rules and best pratices of the Forum. - General - MQL5 programming forum (2017.07.19)

  2. You count down to find the lowest and second lowest. See your previous post.

  3. You count up to find the highest and second.

 
William Roeder:
  1. Don't double post! You already had another thread open.

              General rules and best pratices of the Forum. - General - MQL5 programming forum (2017.07.19)

  2. You count down to find the lowest and second lowest. See your previous post.

  3. You count up to find the highest and second.

I'm not double posting..I just make a specific thread with the right question. 😓😓