Expert Stopped any one can please check this code

 

after the last update my EA stopped open new trades when i check it for errors it gives me this message

return value of 'OrderSelect' should be checked


 

this the code

  {

 OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;

      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {

         if (OrderType() == OP_BUY) {

            LongTrade = TRUE;

            ShortTrade = FALSE;

            break;

         }

      }

      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {

         if (OrderType() == OP_SELL) {

            LongTrade = FALSE;

            ShortTrade = TRUE;

            break;

         }

      }

   }  

 
abdouamer:

after the last update my EA stopped open new trades when i check it for errors it gives me this message


use the SRC button to attach the code otherwise it is no very easy to read

 

and see this  https://www.mql5.com/en/docs/trading/orderselect

Documentation on MQL5: Trade Functions / OrderSelect
Documentation on MQL5: Trade Functions / OrderSelect
  • www.mql5.com
Trade Functions / OrderSelect - Documentation on MQL5
 
abdouamer:

after the last update my EA stopped open new trades when i check it for errors it gives me this message

...

Forum on trading, automated trading systems and testing trading strategies

Hello,

This forum is about MT5/mql5, please post your question about MT4/mql4 on mql4.com forum.

  • They are more people who can answer there.
  • They are more people who can have similar problem there.
  • A forum is not only to get help but to share with the community, mql4/MT4 community isn't the same as mql5/MT5 community.
Actually, the message you get is not an error but a warning.
 
Upload your's and I will do it for you.
 

Change to this

   
   {
      if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
         {
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) 
               {
                  if (OrderType() == OP_BUY) 
                     {
                        LongTrade = TRUE;
                        ShortTrade = FALSE;
                        break;
                     }
               }
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) 
               {
                  if (OrderType() == OP_SELL) 
                     {
                        LongTrade = FALSE;
                        ShortTrade = TRUE;
                        break;
                     }
               }
         }
   }
Reason: