3.3.5Closing all open trades or pending orders on a single market

The following tradingAction types close all the open trades and/or pending orders on a single market. They simply save your code having to scan the Framework.Orders list and build its own list of individual trading requests. With some types of account/back-end trading platform the framework may be able to use a more optimised trading request than closing each order/trade individually.

For the following actions, an instrumentId for the FXB.Instrument is compulsory. No other values are required or used.

For example, you can close all the loss-making open trades on EUR/USD with the following request:

Framework.SendOrder({

tradingAction: FXB.OrderTypes.CLOSEPOSLOSERS,

instrumentId: "EUR/USD"

}, function (MsgResult) {

});

FXB.OrderTypes.

Description

CLOSEPOSITION

Closes all open trades and pending orders on the market

CLOSEPOSTRADES

Closes open trades on the market, but not pending orders

CLOSEPOSPENDING

Closes pending orders, but not open trades

CLOSEPOSWINNERS

Closes profitable open trades (netProfit > 0)

CLOSEPOSLOSERS

Closes loss-making open trades (netProfit < 0)

CLOSEPOSLONG

Closes all long trades and pending orders

CLOSEPOSSHORT

Closes all short trades and pending orders

HEDGEPOSITION

If supported by the account, hedges the current position by placing an open trade in the opposite direction for the current open volume. For example, you are currently short 20,000 EUR/USD this will open a buy trade for 20,000. Not allowed if the account is netting/non-hedging.

DOUBLEPOSITION

Doubles the current position. For example, if you are currently (net) short 20,000 EUR/USD this will open a new sell trade for a further 20,000

REVERSEPOSITION

Reverses the current position by placing a new trade for the opposite volume, without closing the current open trade(s). For example, if you are currently short 20,000 EUR/USD this will open a buy trade for 40,000. Not allowed if the account is netting/non-hedging.

CLOSEANDREVERSE

Like REVERSEPOSITION, but closes the current open trade(s) rather than just opening a new trade in the opposite direction, and is therefore permitted on netting/non-hedging accounts. For example, if you are currently short 20,000 EUR/USD this will close the existing open trade(s) and open a new buy trade for 20,000.