Edit Order

Only Entry Stop (SE), Entry Limit (LE), Stop (S) and Limit (L) orders (and all their modifications) in the Waiting ("W") state can be changed.

To edit an order, please fill the following values in the value map:

Parameter name

Datatype

Description

Command

const char *

The command. Must be EditOrder.

The field is obligatory.

OrderID

const char *

The identifier of the order to be changed.

The field is obligatory.

AccountID

const char *

The identifier of the account the order was placed for. The value must be obtained from the Accounts table, the AccountID column.

Please note that the account identifier may not necessarily be equal to the account name which is shown in the Trading Station application.

The field is obligatory.

Rate

double

A new rate for the order.

For sell stop and buy limit orders, the rate must be below the market.

For sell limit and buy stop orders, the rate must be above the market.

If you want to change the rate of the order, you must specify either Rate or a pair of PegOffset and PegType fields. If none of the three fields are specified, the price will not be changed.

PegType

const char *

The type of the pegged (relative to market) price. Possible values:

O

Can be used only for stop and limit orders attached to the trade. In that case the offset will be added to the open price of the trade.

M

Can be used for any order. In that case the offset will be added to the market price.

Please note that only stop and limit orders which are attached to the entry order can be kept in the pegged price. For all other kinds of the orders, the pegged price will be automatically converted to a regular price.

PegOffset

int

An offset, expressed in pips, against the price specified in the PegType parameter.

For sell stop and buy limit orders, the offset must be negative.

For sell limit and buy stop orders, the offset must be positive.

Price can be specified as an offset to the market only for Stop or Limit orders attached to an entry order.

TrailStep

int

The value can be changed for an entry order or for a stop order.

The value specifies the maximum change of the market price after which the rate of the order will be changed as well.

The value is expressed in the units of the minimum change of the price (see the Digits column of the Offers table). For example, if the value of the Digits column is 3 and the value of TrailStep is 5, the maximum change of the market price will be 5 * 10-3 = 0.005.

If the value is 1, it means that the dynamic trailing mode is used, i.e. the order rate is changed with every change of the market price. Please note that in some systems, only dynamic trailing mode is supported.

By default, this value is 0. 0 means no-trailing order.

If value is not specified, the trailing mode will not be changed.

The trailing mode can be changed for the SE, LE and S orders only.

Amount

int

The amount of the order. In the case of FX instruments, the amount is expressed in the base currency of an instrument. In the case of CFD instruments, the amount is expressed in contracts. Must be divisible by the value of the lot size.

The amount can be changed for entry orders which are not in the netting mode.

If value is not specified, the order amount will not be changed.

CustomID

const char *

The custom identifier of the order. This value will be populated into these columns of the trading tables:

Table

Column for opening order

Column for closing order

Orders

RequestTXT

RequestTXT

Trades

OpenOrderRequestTXT

N/A

Closed Trades

OpenOrderRequestTXT

CloseOrderRequestTXT

If value is not specified, the custom identifier of the order will not be changed.

Not all combinations of the fields can be used. Please follow the rules below:

1) Rate can be changed either using the Rate field or a pair of PegType and PegOffset fields. Pegged price (a price expressed as a distance in pips) can be changed only for S or L orders attached to entry orders. For all other kinds of orders, the Rate must be used to change the order rate. If the rate is changed, TrailStep must be also specified. If you omit the TrailStep field, the trailing mode of the order will be reset, even if the order was trailing. Moreover, even if you need to change only the trailing mode, the rate must be specified.

2) You can change both rate (plus trailing mode) and amount, as well as only rate or amount.

Example: Edit an order [hide]

  void CreateOrderSample::editOrder(const char *orderID, const char* accountID, int amount, double rate)
  {
      using namespace O2G2;
      O2G2Ptr<IO2GRequestFactory> factory = mSession->getRequestFactory();
 
      O2G2Ptr<IO2GValueMap> valuemapChangeOrder = factory->createValueMap();
      valuemapChangeOrder->setString(Command, "EditOrder");
      valuemapChangeOrder->setString(OrderID, orderID);
      valuemapChangeOrder->setString(AccountID, accountID);
      valuemapChangeOrder->setDouble(Rate, rate);
      valuemapChangeOrder->setInt(Amount, amount);
      valuemapChangeOrder->setString(CustomID, "EditOrder");
 
      O2G2Ptr<IO2GRequest> requestChangeOrder = factory->createOrderRequest(valuemapChangeOrder);
      mSession->sendRequest(requestChangeOrder);
 
  }

back