- initialize
- login
- shutdown
- version
- last_error
- account_info
- terminal_info
- symbols_total
- symbols_get
- symbol_info
- symbol_info_tick
- symbol_select
- market_book_add
- market_book_get
- market_book_release
- copy_rates_from
- copy_rates_from_pos
- copy_rates_range
- copy_ticks_from
- copy_ticks_range
- orders_total
- orders_get
- order_calc_margin
- order_calc_profit
- order_check
- order_send
- positions_total
- positions_get
- history_orders_total
- history_orders_get
- history_deals_total
- history_deals_get
order_send
Send a request to perform a trading operation from the terminal to the trade server. The function is similar to OrderSend.
order_send(
|
Parameters
request
[in] MqlTradeRequest type structure describing a required trading action. Required unnamed parameter. Example of filling in a request and the enumeration content are described below.
Return Value
Execution result as the MqlTradeResult structure. The request field in the answer contains the structure of a trading request passed to order_send().
The MqlTradeRequest trading request structure
Field |
Description |
---|---|
action |
Trading operation type. The value can be one of the values of the TRADE_REQUEST_ACTIONS enumeration |
magic |
EA ID. Allows arranging the analytical handling of trading orders. Each EA can set a unique ID when sending a trading request |
order |
Order ticket. Required for modifying pending orders |
symbol |
The name of the trading instrument, for which the order is placed. Not required when modifying orders and closing positions |
volume |
Requested volume of a deal in lots. A real volume when making a deal depends on an order execution type. |
price |
Price at which an order should be executed. The price is not set in case of market orders for instruments of the "Market Execution" (SYMBOL_TRADE_EXECUTION_MARKET) type having the TRADE_ACTION_DEAL type |
stoplimit |
A price a pending Limit order is set at when the price reaches the 'price' value (this condition is mandatory). The pending order is not passed to the trading system until that moment |
sl |
A price a Stop Loss order is activated at when the price moves in an unfavorable direction |
tp |
A price a Take Profit order is activated at when the price moves in a favorable direction |
deviation |
Maximum acceptable deviation from the requested price, specified in points |
type |
Order type. The value can be one of the values of the ORDER_TYPE enumeration |
type_filling |
Order filling type. The value can be one of the ORDER_TYPE_FILLING values |
type_time |
Order type by expiration. The value can be one of the ORDER_TYPE_TIME values |
expiration |
Pending order expiration time (for TIME_SPECIFIED type orders) |
comment |
Comment to an order |
position |
Position ticket. Fill it when changing and closing a position for its clear identification. Usually, it is the same as the ticket of the order that opened the position. |
position_by |
Opposite position ticket. It is used when closing a position by an opposite one (opened at the same symbol but in the opposite direction). |
Note
A trading request passes several verification stages on the trade server. First, the validity of all the necessary request fields is checked. If there are no errors, the server accepts the order for further handling. See the OrderSend function description for the details about executing trading operations.
Example:
import time
|
See also
order_check, OrderSend,Trading operation types, Trading request structure, Structure of the trading request check results, Structure of the trading request result