Close Trade
CloseTrade¶
Closes an existing trade based on the provided trade parameters.
int CloseTrade(const TradeRecord& source_trade);
Parameters¶
- source_trade — constant reference to a TradeRecord structure containing the trade parameters for closing the trade.
Return Value¶
RET_OK— trade successfully closed.RET_*— error code returned by the internal checks or close operation.- Return Codes
Example¶
TradeRecord tr = {};
tr.order = 123456;
tr.login = 1001;
tr.symbol = "EURUSD";
tr.volume = 1000;
tr.close_price = 1.0750;
if (CloseTrade(tr) == RET_OK) {
// Trade closed successfully
}
Warning
- The trade parameters in
source_trademust refer to an existing and valid open trade. - The function may perform pre-close checks before attempting to close the trade.
- Always check the return code to ensure the trade was closed successfully.