MT5.MultipleOrders: Send multiple orders

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/Source_MT5.R

Description

Send 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.

Usage

1
MT5.MultipleOrders(df_orders)

Arguments

df_orders

data.frame; see details.

Details

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.

Using fPrice = 0 for Market Order, automatically iFillType will be set to 1.

Value

Returns {logical} vector. TRUE if order was successful accepted, otherwise will return FALSE.

Author(s)

Guilherme Kinzel, guikinzel@gmail.com

References

https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties

https://www.investopedia.com/terms/m/marketorder.asp

See Also

MT5.SingleOrder(), MT5.ShowOrders(), MT5.ShowPositions(), MT5.ClosePosition(), MT5.DeleteOrder(), MT5.ModifyOrder(), MT5.ModifyPosition()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
## 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)


## End(Not run)

Kinzel/mt5r documentation built on March 25, 2021, 9:57 p.m.