Syntax
Public Function CloseMultiPositions(PositionIDs As string, Lots As String) As Boolean
Description
This function is used to close multiple market orders at once.To get a result from the server, you have to consumeOnOrderTradeevent(when auto broker off)orOnPositionTradeevent (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), Avalue 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