- www.mql5.com
- www.mql5.com
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.
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
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
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; } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi i have a script in mql4 i want convert in mql5 i have a part in mql4 that do this
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