Skip to content

Open Trade

OpenTrade

Opens a trade based on the provided trade parameters.

int OpenTrade(const TradeRecord& trade);

Parameters

  • trade — constant reference to a TradeRecord structure containing the trade parameters to be opened.

Return Value

  • RET_OK — trade successfully opened.
  • RET_* — error code returned by the internal checks or trade execution.
  • Return Codes

Example

TradeRecord tr = {};
tr.login = 1001;
tr.symbol = "EURUSD";
tr.cmd = OP_BUY;
tr.volume = 1000;
tr.sl = 1.0500;
tr.tp = 1.0800;

if (OpenTrade(tr) == RET_OK) {
    // Trade opened successfully
}

Warning

  • The trade parameters in trade must be valid and comply with all system rules.
  • If the check fails, the trade will not be opened.
  • Always check the return code to ensure the trade was placed successfully.