Download MetaTrader 5

Please help me with " return value of "OrderSelect" should be checked"

To add comments, please log in or register
Kyong Duk Hong
147
Kyong Duk Hong  

Hello,

I am trying to solve "return value of "orderSelect" should be checked" from the following code.

for(cnt=0;cnt<OrdersTotal();cnt++)
   {
      OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
         if(OrderType()==OP_BUY&&OrderSymbol()==Symbol()&&((OrderMagicNumber()==Magic)||Magic==0))
            {
               if(CB==1)
               {
                  OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Red);return(0);
               }
            }
      
         if(OrderType()==OP_SELL&&OrderSymbol()==Symbol()&&((OrderMagicNumber()==Magic)||Magic==0))
            {
               if(CS==1)
               {
                  OrderClose(OrderTicket(),OrderLots(),Ask,Slip,Red);return(0);
               }
            }
   }
double SLI=0,TPI=0;int TK=0;
Thanks for the help.
Jack Thomas
2162
Jack Thomas  

It's a bool value.

if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)==true){ /* do something here for true */ }

When in doubt, read the documentation.

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 - Reference on algorithmic/automated trading language for MetaTrader 5
Drazen Penic
2730
Drazen Penic  

You could try this:  http://bit.ly/2u9zHin

Or this: http://bfy.tw/Ckiy

LMGTFY
LMGTFY
  • lmgtfy.com
LMGTFY
To add comments, please log in or register