Syntax
Public Function CloseMarketOrder(ticketID As Long, vLots As Double) As Boolean
Description
This function is used to close the market order by given ticket number.To get a result from the server, you have to consumeOnOrderTradeevent(when auto broker off) or OnPositionTrade event (when auto broker on).
Parameters
Key | Description |
ticketID | Position ticket number to be closed, a value of type Long. |
vLots | Amount of lots, A value of type Double. |
Return value
Returns true if successful, otherwise returns false. In order to get an error, call GetLastError() function.
Sample
Public Sub main () If AccountInfoInteger (ACCOUNT_LOGIN) Then Dim ticket Dim lot Dim Symbol Symbol = ChartSymbol (0) Ticket = PositonGetTicket (1) PositionSelect Clng (Ticket) PositionGetDouble POSITION_AMOUNT, lot If (GetPositionSymbol () = Symbol) then If CloseMarketOrder (ticket, lot) = false then AlertMessage ErrorDescription (GetLastError ()) End IF End IF End IF End sub
See Also