- LogLevel
- SetExpertMagicNumber
- SetDeviationInPoints
- SetTypeFilling
- SetTypeFillingBySymbol
- SetAsyncMode
- SetMarginMode
- OrderOpen
- OrderModify
- OrderDelete
- PositionOpen
- PositionModify
- PositionClose
- PositionClosePartial
- PositionCloseBy
- Buy
- Sell
- BuyLimit
- BuyStop
- SellLimit
- SellStop
- Request
- RequestAction
- RequestActionDescription
- RequestMagic
- RequestOrder
- RequestSymbol
- RequestVolume
- RequestPrice
- RequestStopLimit
- RequestSL
- RequestTP
- RequestDeviation
- RequestType
- RequestTypeDescription
- RequestTypeFilling
- RequestTypeFillingDescription
- RequestTypeTime
- RequestTypeTimeDescription
- RequestExpiration
- RequestComment
- RequestPosition
- RequestPositionBy
- Result
- ResultRetcode
- ResultRetcodeDescription
- ResultDeal
- ResultOrder
- ResultVolume
- ResultPrice
- ResultBid
- ResultAsk
- ResultComment
- CheckResult
- CheckResultRetcode
- CheckResultRetcodeDescription
- CheckResultBalance
- CheckResultEquity
- CheckResultProfit
- CheckResultMargin
- CheckResultMarginFree
- CheckResultMarginLevel
- CheckResultComment
- PrintRequest
- PrintResult
- FormatRequest
- FormatRequestResult
PositionClose
Closes a position by the specified symbol.
bool PositionClose(
|
Closes a position with the specified ticket.
bool PositionClose(
|
Parameters
symbol
[in] Name of trade instrument, by which it is intended to close position.
ticket
[in] Ticket of a closed position.
deviation=ULONG_MAX
[in] Maximal deviation from the current price (in points).
Return Value
true - successful check of the basic structures, otherwise - false.
Note
Successful completion of the PositionClose(...) method does not always mean successful execution of the trade operation. It is necessary to check the result of trade request (trade server return code) using ResultRetcode().
For the "netting" interpretation of positions (ACCOUNT_MARGIN_MODE_RETAIL_NETTING and ACCOUNT_MARGIN_MODE_EXCHANGE), only one position can exist for a symbol at any moment of time. This position is a result of one or more deals. Do not confuse positions with valid pending orders, which are also displayed on the Trading tab of the Toolbox window.
If individual positions are allowed (ACCOUNT_MARGIN_MODE_RETAIL_HEDGING), multiple positions can be open for one symbol. In this case, PositionClose will close a position with the lowest ticket.