stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

return value of 'OrderClose' should be checked
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3665
Page 1 of 1
Author:  apnihost [ Wed Jun 04, 2014 10:28 am ]
Post subject:  return value of 'OrderClose' should be checked

need help fix this

return value of 'OrderClose' should be checked PipsClick-v1.5.mq4 167 14
return value of 'OrderClose' should be checked PipsClick-v1.5.mq4 170 14


Code: Select all

int TradeStart=0;
int start()
  {Comment("");startto();
//  indicator();
  

  if (Hour()>=(StartHour+GMT)&&Minute()>=StartMinute) 
  TradeStart=1;
  
  if (Hour()>=(EndHour+GMT  )&&Minute()>=EndMinute  )
  TradeStart=0;

if (StartHour==0&&StartMinute==0&&EndHour==0&&EndMinute==0)
TradeStart=1;

if (TradeStart==0)
{
   for(int zz=OrdersTotal()-1; zz>=0; zz--)
      if(OrderSelect(zz,SELECT_BY_POS))
         if(OrderSymbol()==Symbol() )
         if(OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
             OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,Red);
            //---------------------------------      
            if(OrderType()==OP_SELL)
             OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,Red);
           }


}
Author:  milanese [ Wed Jun 04, 2014 10:31 am ]
Post subject:  return value of 'OrderClose' should be checked

apnihost ยป Wed Jun 04, 2014 10:28 am wrote:need help fix this

return value of 'OrderClose' should be checked PipsClick-v1.5.mq4 167 14
return value of 'OrderClose' should be checked PipsClick-v1.5.mq4 170 14

...
Just do it this way:

Code: Select all

int TradeStart=0;
int start()
  {Comment("");startto();
//  indicator();
  

  if (Hour()>=(StartHour+GMT)&&Minute()>=StartMinute) 
  TradeStart=1;
  
  if (Hour()>=(EndHour+GMT  )&&Minute()>=EndMinute  )
  TradeStart=0;

if (StartHour==0&&StartMinute==0&&EndHour==0&&EndMinute==0)
TradeStart=1;

if (TradeStart==0)
{
   for(int zz=OrdersTotal()-1; zz>=0; zz--)
      if(OrderSelect(zz,SELECT_BY_POS))
         if(OrderSymbol()==Symbol() )
         if(OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
             bool order_closeBUY=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,Red);
            //---------------------------------      
            if(OrderType()==OP_SELL)
               bool order_closeSELL=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,Red);
           }


}
Author:  apnihost [ Wed Jun 04, 2014 10:36 am ]
Post subject:  return value of 'OrderClose' should be checked

Thanks So much :yahoo:
Author:  SteveHopwood [ Wed Jun 04, 2014 9:43 pm ]
Post subject:  return value of 'OrderClose' should be checked

Tommaso is dead right - he always is. :clap:

Having said that, you will save yourself a lot of Crqpql4/5/x angst by learning the difference between an 'error' which will stop your compilation, and a 'warning' which will not.


:xm:
All times are UTC Page 1 of 1