OrderClose - Trade Functions - MQL4 Reference

MQL4 Reference Trade Functions OrderClose

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.

Example:

  if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75)
    {
     OrderClose(order_id,1,Ask,3,Red);
     return(0);
    }