OrderCalcMargin

The function calculates the margin required for the specified order type, on the current account, in the current market environment not taking into account current pending orders and open positions. It allows the evaluation of margin for the trade operation planned. The value is returned in the account currency.

bool  OrderCalcMargin(
   ENUM_ORDER_TYPE       action,           // type of order
   string                symbol,           // symbol name
   double                volume,           // volume
   double                price,            // open price
   double&               margin            // variable for obtaining the margin value
   );

Parameters

action

[in]  The order type, can be one of the values of the ENUM_ORDER_TYPE enumeration.

symbol

[in]  Symbol name.

volume

[in]  Volume of the trade operation.

price

[in]  Open price.

margin

[out]  The variable, to which the value of the required margin will be written in case the function is successfully executed. The calculation is performed as if there were no pending orders and open positions on the current account. The margin value depends on many factors, and can differ in different market environments.

Return Value

The function returns true in case of success; otherwise it returns false. In order to obtain information about the error, call the GetLastError() function.

See also

OrderSend(), Order Properties, Trade Operation Types