orderclose mql4 and positionclose in mql5 why is not equal ?

 

Hi i have  a script  in mql4   i want  convert in mql5 i have  a part in mql4  that do this

 if(OrderClose(VarOrder1,Size,0,SlippaGe,Red)==False)
                            {

i find in manual relative orderclose and is PositionClose , but in position close  have only 2 param , how  is possible that ? if  i want close a partial trade ?? i can't in mql5? thanks


 
You should check the documentation.
Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionClose
Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionClose
  • www.mql5.com
Closes a position by the specified symbol. Closes a position with the specified ticket. Parameters symbol [in]  Name of trade instrument, by...
 
Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionClosePartial
Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionClosePartial
  • www.mql5.com
Partially closes a position on a specified symbol in case of a "hedging" accounting. Partially closes a position having a specified...
 
faustf: i have  a script  in mql4   i want  convert in mql5 i have  a part in mql4  that do this

 if(OrderClose(VarOrder1,Size,0,SlippaGe,Red)==False)

In MT4, there are only orders (pending, active, and history). In MT5 there are orders (pending), deals (opened), and positions. Learn the language.

 
sorry but i continue  not uderstund how is possible use  in MT4 orderclose close  the trade in base of ticket
bool  OrderClose(
   int        ticket,      // ticket 



the ticket is univoque for a specific trade , but in Mt5 i have (for example)

bool  PositionClose(
   const string  symbol, 


symbol is not unique  exist somthing similar in mql5 ? or  how can do close byticket ?

i finded

bool  PositionCloseBy(
   const ulong   ticket,        // position ticket
   const ulong   ticket_by      // opposite position ticket
   )

but  

const ulong   ticket_by      // opposite position ticket ???  why ????  i am in CFD i try to use  without this param ,

 if(PositionCloseBy(VarOrder1)==False)

but my editor not  highligh the keyword PositionCloseBy  and return me

  'PositionCloseBy' - undeclared identifier    SPREAD_ROBOT.mq5    258    32
  

 
faustf #:
sorry but i continue  not uderstund how is possible use  in MT4 orderclose close  the trade in base of ticket



the ticket is univoque for a specific trade , but in Mt5 i have (for example)


symbol is not unique  exist somthing similar in mql5 ? or  how can do close byticket ?

i finded

but  

const ulong   ticket_by      // opposite position ticket ???  why ????  i am in CFD i try to use  without this param ,

but my editor not  highligh the keyword PositionCloseBy  and return me


It is not possible to use mt4 order code in mt5. They work differently 
You need to read the manual or look at some of the articles that cover the subject 
 
Paul Anscombe #:
It is not possible to use mt4 order code in mt5. They work differently 
You need to read the manual or look at some of the articles that cover the subject 

not exist something library that do this ? 

 
faustf #:

not exist something library that do this ? 

Have you even tried searching?  It maybe someone has made a library 
 

i suppose  with this code i can close thanks so much i share with all comunity  thanks again

// Function to close an order by its ticket
bool OrderClose(int ticket) {
   if (PositionSelectByTicket(ticket)) {
      double price = SymbolInfoDouble(_Symbol, SYMBOL_BID); // Get current price
      double lotSize = PositionGetDouble(POSITION_VOLUME);
      double slippage = 2; // Slippage in pips

      // Send a close order
      int result = OrderSend(_Symbol, 
                             OP_SELL, 
                             lotSize, 
                             price, 
                             slippage, 
                             , 
                             , 
                             "Close order", 
                             ticket, 
                             , 
                             clrNONE);

      // Check if order was closed successfully
      if (result > ) {
         Print("Order closed successfully: ", ticket);
         return true;
      } else {
         Print("Error closing order: ", GetLastError());
         return false;
      }
   } else {
      Print("Order not found: ", ticket);
      return false;
   }
}