Market Order

Market order is an order to buy or sell currency immediately at the best available market price. One can create a BUY and/or SELL market order by using a method IEngine.submitOrder).

Submit market order

Buy market order of 100'000 in EUR/USD:

IOrder order = engine.submitOrder("MyMaketBuyOrder", Instrument.EURUSD, OrderCommand.BUY, 0.1);

Sell market order of 100'000 in EUR/USD:

IOrder order = engine.submitOrder("MyMarketSellOrder", Instrument.EURUSD, OrderCommand.SELL, 0.1);

Submit market order with slippage

In the two above methods the default slippage of 5 pips gets applied. It is also possible to specify a different slippage value by using the IEngine.submitOrder method with a price and slippage parameters. If zero price is used as parameter, then the latest market price will get used. Consider making a BUY market order of 100'000 in EUR/USD with slippage of 2 pips. double price = 0;

double price = 0;
int slippage = 2;
engine.submitOrder("OrderLabel", Instrument.EURUSD, OrderCommand.BUY, 0.1, price, slippage);
As soon as the market order is submitted order price will be equal to 0 and after the order is filled open price will be changed.
The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.