MT5.MultipleOrders.RdSend multiple orders using data.frame. All columns need to be filled. See details.
Some Forex brokers take 200ms to accept orders into market, so take this time on mind. Always check MT5's "Experts" tab.
MT5.MultipleOrders(df_orders)
| df_orders | data.frame; see details. |
|---|
Returns {logical} vector. TRUE if order was successful accepted, otherwise will return FALSE.
Take note that buy orders are rejected when order's stop loss are higher than order's price, and vice-versa for sell orders. This is a sanity check made by MT5, not by mt5R. Always check MT5's "Experts" tab for more details when an order is rejected.
df_orders {data.frame} \([nx7]\) columns should be on the same order and type of MT5.SingleOrder arguments.
sSymbol {character}: symbol to send the order.
iCmd {int}:
0: ORDER_TYPE_BUY_LIMIT
1: ORDER_TYPE_SELL_LIMIT
fVol {numeric}: volume order.
fPrice {numeric}: where the order will be positioned. Use fPrice = 0 for market order.
fStop {numeric}: if applicable use any value > 0.
fGain {numeric}: if applicable use any value > 0.
iFillType {int}:
0: ORDER_FILLING_RETURN (default)
1: ORDER_FILLING_FOK (market order)
2: ORDER_FILLING_IOC
Using fPrice = 0 for Market Order, automatically iFillType will be set to 1.
https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
https://www.investopedia.com/terms/m/marketorder.asp
MT5.SingleOrder(), MT5.ShowOrders(), MT5.ShowPositions(), MT5.ClosePosition(), MT5.DeleteOrder(), MT5.ModifyOrder(), MT5.ModifyPosition()
if (FALSE) { ## Two LONG positions, PETR4 with volumn of 100 and price of 22.0 and VALE5 with volumn of 500 and price of 65. Orders <- data.frame(sSymbol = "PETR4", iCmd = 0, fVol = 100, fPrice = 22, fStop = 0, fGain = 0, iFillType = 0) Orders <- rbind(Orders, data.frame(sSymbol = "ABEV3", iCmd = 0, fVol = 200, fPrice = 14.3, fStop = 0, fGain = 0, iFillType = 0)) MT5.MultipleOrders(Orders) ## Forex order. First one is a market order (fPrice = 0) Orders <- data.frame(sSymbol = "EURUSD", iCmd = 0, fVol = 0.01, fPrice = 0, fStop = 0, fGain = 0, iFillType = 1) Orders <- rbind(Orders, data.frame(sSymbol = "GBPUSD", iCmd = 0, fVol = 0.01, fPrice = 1.3276, fStop = 0, fGain = 0, iFillType = 0)) MT5.MultipleOrders(Orders) }