3.3.2New pending orders and trades

To open a new pending order or trade (market order), you set the tradingAction to one of the FXB.OrderTypes: BUY, SELL_LIMIT etc. For example:

var request = {

tradingAction: FXB.OrderTypes.SELL_LIMIT,

openPrice: {offset: 0.0020}, // Offset of 0.0020 from current price (bid, because sell)

instrumentId: "EUR/USD",

volume: {lots: 0.20}

};

However, for pending orders, you can use two additional values: BUY_PENDING and SELL_PENDING. These let you tell the framework to work out whether your specified entry price for the pending order is a limit or a stop. If you only care about the entry price, e.g. "enter at 1.23456", and not its position relative to the current market price, then you can set the entry price and use BUY_PENDING or SELL_PENDING, and the framework will convert that into the correct combination of buy/sell and limit/stop, e.g. turning the SELL_PENDING into a SELL_STOP.

Compulsory and optional request properties when opening a new trade or order are as follows:

Example

Description

instrumentId

instrumentId of the FXB.Instrument to trade. Always compulsory.

volume

Volume to trade. Always compulsory.

openPrice

Open price for a pending order. Compulsory on pending orders; ignored on trades. For stop-limit orders, the openPrice is the limit price.

triggerPrice

Trigger (stop) price for stop-limit orders. Compulsory on stop-limit orders; ignored on all other types.

sl

Stop-loss to set on the order/trade. Always optional.

tp

Take-profit to set on the order/trade. Always optional.

trail

Trailing stop to apply to the order/trade. Always optional, and not necessarily available. Requires that the broker account supports trailing stops.

expiry

Optional expiration on pending orders. Ignored on trades.

comment

Textual comment to set on the order/trade, if supported by the back-end platform.

magicNumber

MT4/5-style "magic number" to set on the order/trade, if supported by the back-end platform.