Download MetaTrader 5

Expert Stopped any one can please check this code

To add comments, please log in or register
Abdou Solyman
155
Abdou Solyman  

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;

         }

      }

   }  

Paul Anscombe
4408
Paul Anscombe  
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
Alain Verleyen
Moderator
33603
Alain Verleyen  
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.
Osama Shaban
1689
Osama Shaban  
Upload your's and I will do it for you.
Biantoro Kunarto
18194
Biantoro Kunarto  

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;
                     }
               }
         }
   }
To add comments, please log in or register