Knowledgebase:
CloseMultiPositions
Posted by Mohammad Rahhal, Last modified by Angham Al-Banawien on 03 July 2018 03:08 PM

Syntax

Public Function CloseMultiPositions(PositionIDs As string, Lots As String) As Boolean

This function is used to close multiple market orders at once.To get a result from the server, you have to consume OnOrderTrade event (when auto broker off) or OnPositionTrade event (when auto broker on).

Parameters

Key Description 
PositionIDs Position Ticket IDs for all the Positions to be closed separated by commas, a value of type String.
Lots  Amounts separated by commas (If the amount passed is greater than the available amount, the function will close the entire amount of that position), A value of type String.

Return value

Returns true if successful otherwise, returns false. In order to get an error, call GetLastError() function.

Remark

The number of the PositionIDs and the number of amounts should be identical. And with the same order that you want to close for those PositionIDs.

Sample

 Public Sub main ()

 If AccountInfoInteger (ACCOUNT_LOGIN) Then

 Dim Tickets
 Dim ticket
 Dim lots
 Dim lot
 Dim Symbol
 Dim I

 Symbol = ChartSymbol (0)
      for I = 1 to positionTotal()
          Ticket = PositonGetTicket (I)
          PositionSelect Clng (Ticket)
          If( GetPositionSymbol() = Symbol) then
             Tickets = Ticket & ”,” &  Tickets
             PositionGetDouble POSITION_AMOUNT, lot
             Lots = lot & ”,” & Lots  
          End IF
      Next
   If CloseMultiPositions(tickets, lots)= false then
   AlertMessage ErrorDescription(GetLastError())
   End IF
  End IF

  End sub


See Also

 

Back to VTL Client Script Index

(1 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
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