Posted by Mohammad Rahhal, Last modified by Diana Alkouni on 02 September 2020 10:15 AM


Public Function CloseMarketOrder(ticketID As Long, vLots As Double) As Boolean


This function is used to close the market order by given ticket number.To get a result from the server, you have to consume OnOrderTrade event (when auto broker off) or OnPositionTrade event (when auto broker on).


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.


 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

Back to VTL Client Script Index

(0 vote(s))
Not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Help Desk Software by Hybrid Solutions