some operator expected

 

hi

I'm new in programming. 

can you please help me to find out what's the problem with this part of my EA ?

I've  got this Error : 'totallots'- some operator expected 

double TotalLots ()

{



double totalots=0;


for(int i=0; i<OrdersTotal(); i++)


   {

       OrderSelect(i, SELECT_BY_POS, MODE_TRADES)


          totalots+=OrderLots(); 

   }

return(0);

}

 

OrderSelect() should be checked in case of an error and TotalLots() should return a value.

double TotalLots ()
  
  {

   double totalots=0;

   for(int i=0; i<OrdersTotal(); i++)

     {

       if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       
          continue;

       totalots+=OrderLots(); 

     }

   return(totalots);

  }
 

Thank you

and yes  I forgot about return :D 

but   about the other problem , is the error " return value of OrderClose should be cheked" in codes below has same problem ?

void AllOrdersClose ()

   {

   for(int i=OrdersTotal()-1 ; i>=0 ; i-- )

     {

     while(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)

         {

           OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_ASK),Slippage,Green);

           OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),Slippage,Green);

         }

      }

     } 


Sorry for bad english

 
dr.Rez:

Thank you

and yes  I forgot about return :D 

but   about the other problem , is the error " return value of OrderClose should be cheked" in codes below has same problem ?

void AllOrdersClose ()

   {

   for(int i=OrdersTotal()-1 ; i>=0 ; i-- )

     {

     while(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)

         {

           OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_ASK),Slippage,Green);

           OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),Slippage,Green);

         }

      }

     } 


Sorry for bad english

Don't you like to verify that the order was indeed closed, and take additional action if it did not succeed?

OrderClose()


Returns a value, and the compiler is telling you hey you didn't check the return value.

bool result=OrderClose()
 {
  if(result==true)
    {
    Print("Ok");
    }
  else if(result==false)
    {
     Print(OrderClose Error!");
    }
 }
 
Marco vd Heijden:

Returns a value, and the compiler is telling you hey you didn't check the return value.

Thank you 

So OrderClose  not only close position ,but it also  returns a Boolean value that it should be used for checking . right?

I don't know if my English is understandable or not but I hope  it is :)

 
dr.Rez:

Thank you 

So OrderClose  not only close position ,but it also  returns a Boolean value that it should be used for checking . right?

I don't know if my English is understandable or not but I hope  it is :)

Put the cursor on the function in meta editor and press F1.

This will open up the reference library and show you exactly what it returns.

OrderClose

Closes opened order.

bool  OrderClose(
   int        ticket,      // ticket
   double     lots,        // volume
   double     price,       // close price
   int        slippage,    // slippage
   color      arrow_color  // color
   );

Parameters

ticket

[in]  Unique number of the order ticket.

lots

[in]  Number of lots.

price

[in]  Closing price.

slippage

[in]  Value of the maximum price slippage in points.

arrow_color

[in]  Color of the closing arrow on the chart. If the parameter is missing or has CLR_NONE value closing arrow will not be drawn on the chart.

Returned value

Returns true if successful, otherwise false. To get additional error information, one has to call the GetLastError() function.

 
Marco vd Heijden:

Put the cursor on the function in meta editor and press F1.

This will open up the reference library and show you exactly what it returns.

OrderClose

Closes opened order.


 
Thanks a lot 

it was very helpful for me
 
dr.Rez:

hi

I'm new in programming. 

can you please help me to find out what's the problem with this part of my EA ?

I've  got this Error : 'totallots'- some operator expected 

double TotalLots ()

{



double totalots=0;


for(int i=0; i<OrdersTotal(); i++)


   {

       OrderSelect(i, SELECT_BY_POS, MODE_TRADES)


          totalots+=OrderLots(); 

   }

return(0);

}

Some expected operator is semicolon after OrderSelect

      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

 
Slawa:

Some expected operator is semicolon after OrderSelect

      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

really ? :))
thank you so much Slawa
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".