-
Notifications
You must be signed in to change notification settings - Fork 14
Trading API
OrderClose
OrderCloseBy
OrderClosePrice
OrderCloseTime
OrderComment
OrderComission
OrderDelete
OrderExpiration
OrderLots
OrderModify
OrderOpenPrice
OrderOpenTime
OrderPrint
OrderProfit
OrderSelect
OrderSend
OrdersHistoryTotal
OrderStopLoss
OrdersTotal
OrderSwap
OrderSymbol
OrderTakeProfit
OrderTicket
OrderType
OrderStatus
Closes open order
protected bool OrderClose(int ticket, double lots, double price, int slippage, color Color = default(color))
- ticket - Unique number of the order ticket
- lots - Number of lots
- price - Closing price
- slippage - Value of the maximum slippage in points
- Color - Color of the closing arrow on the chart. If the parameter is missing or has CLR_NONE value closing arrow will not be drawn on the chart
- Returns true if successful, otherwise false
Closes an opened order by another opposite opened order
protected bool OrderCloseBy(int ticket, int opposite, color Color = default(color))
- ticket - Unique number of the order ticket
- opposite - Unique number of the opposite order ticket
- Color - Color of the closing arrow on the chart. If the parameter is missing or has CLR_NONE value closing arrow will not be drawn on the chart
- Returns true if successful, otherwise false
Returns close price of the currently selected order
protected double OrderClosePrice()
- The close price of currently selected order
Returns close time of the currently selected order
protected datetime OrderCloseTime()
- Close time for the currently selected order. If order close time is not 0, then the order selected and has been closed and retrieved from the account history. Open and pending orders close time is equal to 0.
- The order must be previously selected by the OrderSelect() function.
Returns comment of the currently selected order
protected string OrderComment()
- Comment of the currently selected order
Returns calculated commission of the currently selected order
protected double OrderCommission()
- The calculated commission of the currently selected order
- The order must be previously selected by the OrderSelect() function.
Deletes previously opened pending order
protected bool OrderDelete(int ticket, color Color = default(color))
- ticket - Unique number of the order ticket
- Color - Color of the delete arrow on the chart. If the parameter is missing or has CLR_NONE value closing arrow will not be drawn on the chart
- If the function succeeds, it returns true, otherwise false
Returns expiration date of the selected pending order
protected datetime OrderExpiration()
- Expiration date of the selected pending order
Returns amount of lots of the selected order
protected double OrderLots()
- Amount of lots (trade volume) of the selected order
- The order must be previously selected by the OrderSelect() function.
Modification of characteristics of the previously opened or pending orders
protected bool OrderModify(int ticket, double price, double stoploss, double takeprofit, datetime expiration)
- ticket - Unique number of the order ticket
- price - New open price of the pending order
- stoploss - New stoploss level
- takeprofit - New takeprofit level
- expiration - Pending order expiration time
- If the function succeeds, it returns true, otherwise false
Returns open price of the currently selected order
protected double OrderOpenPrice()
- Open price of the currently selected order
- The order must be previously selected by the OrderSelect() function.
Returns open time of the currently selected order
protected datetime OrderOpenTime()
- Open time of the currently selected order
Prints information about the selected order in the log and app journal
protected void OrderPrint()
- The order must be previously selected by the OrderSelect() function.
Returns profit of the currently selected order
protected double OrderProfit()
- Profit of the currently selected order
- The order must be previously selected by the OrderSelect() function.
The function selects an order for further processing
protected bool OrderSelect(int index, int select, int pool = MODE_TRADES)
- index - Order index or order ticket depending on the second parameter
-
select - Selecting flags. It can be any of the following values:
- SELECT_BY_POS - index in the order pool
- SELECT_BY_TICKET - index is order ticket
-
pool - Optional order pool index. Used when the selected parameter is SELECT_BY_POS. It can be any of the following values:
- MODE_TRADES (default)- order selected from trading pool(opened and pending orders)
- MODE_HISTORY - order selected from history pool (closed and canceled order)
- It returns true if the function succeeds, otherwise false
The main function used to open market or place a pending order
protected int OrderSend(string symbol, int cmd, double volume, double price,
int slippage, double stoploss, double takeprofit, string comment = default(string),
int magic = 0, datetime expiration = null, color arrow_color = default(color))
- symbol - Symbol for trading
- cmd - Operation type. It can be any of the Trade operation enumeration
- volume - Number of lots
- price - Order price
- slippage - Maximum price slippage for buy or sell orders
- stoploss - Stop loss level
- takeprofit - Take profit level
- comment - Order comment text. Last part of the comment may be changed by server
- magic - Order magic number. May be used as user defined identifier (0 default)
- expiration - Order expiration time (for pending orders only)
- arrow_color - Color of the opening arrow on the chart. If parameter is missing or has CLR_NONE value opening arrow is not drawn on the chart
- Number of the ticket assigned to the order by the trade server or -1 if it fails
Returns the number of closed orders in the account history loaded into the terminal
protected int OrdersHistoryTotal()
- The number of closed orders in the account history loaded into the terminal
Returns stop loss value of the currently selected order
protected double OrderStopLoss()
- Stop loss value of the currently selected order
- The order must be previously selected by the OrderSelect() function.
Returns the number of market and pending orders
protected int OrdersTotal()
- Total amount of market and pending orders
Returns swap value of the currently selected order
protected double OrderSwap()
- Swap value of the currently selected order
- The order must be previously selected by the OrderSelect() function.
Returns symbol name of the currently selected order
protected string OrderSymbol()
- The symbol name of the currently selected order
- The order must be previously selected by the OrderSelect() function.
Returns take profit value of the currently selected order
protected double OrderTakeProfit()
- Take profit value of the currently selected order
- The order must be previously selected by the OrderSelect() function.
Returns ticket number of the currently selected order
protected int OrderTicket()
- Ticket number of the currently selected order
- The order must be previously selected by the OrderSelect() function.
Returns order operation type of the currently selected order
protected int OrderType()
- Order operation type of the currently selected order. It can be any of the following values:
- OP_BUY - buy order
- OP_SELL - sell order
- OP_BUYLIMIT - buy limit pending order
- OP_BUYSTOP - buy stop pending order
- OP_SELLLIMIT - sell limit pending order
- OP_SELLSTOP - sell stop pending order
- The order must be previously selected by the OrderSelect() function.
Returns the status of the currently selected order
protected int OrdersStatus()
- OrderStatus of the currently selected order. It can be any of the following values:
- Unknown = -1,
- PendingNew = 0,
- New = 1,
- Filled = 2,
- Processing = 3,
- Deleted = 32,
- Closed = 33,
- Rejected = 34
- The order must be previously selected by the OrderSelect() function.