Create an Entry Stop Order
A regular entry order opens a position when the specified market condition is met.
A netting entry order closes all positions for the specified instrument and account which are in the direction (buy or sell) opposite to the direction of the entry order.
A stop entry order with a sell direction is filled when the market is below the rate specified in the order.
A stop entry order with a buy direction is filled when the market is above the rate specified in the order.
Please note that if hedging is disabled for the account, the order, first, closes existing opposite positions for the same account and instrument and only then opens a new position in the remaining amount.
Parameter name |
Datatype |
Description |
||||||||||||
Command |
string |
The command. Must be |
||||||||||||
OrderType |
string |
The type of the order. Must be |
||||||||||||
OfferID |
string |
The identifier of the instrument the order should be placed for.
The value must be obtained from the Offers table, the |
||||||||||||
AccountID |
string |
The identifier of the account the order should be placed for.
The value must be obtained from the Accounts table, the Please note that the account identifier may not necessarily be equal to the account name which is shown in the Trading Station application. |
||||||||||||
BuySell |
string |
The order direction. The value must be |
||||||||||||
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 must not be specified in case the |
||||||||||||
NetQuantity |
string |
The net quantity flag. Use this parameter with the value An entry order in the netting mode does not create any positions but closes all positions which
exist at the moment of the order filling and which are created for the
order account and order instrument in the direction (see |
||||||||||||
Rate |
double |
The rate at which the order must be filled. The sell order rate must be below the market. The buy order rate must be above the market. |
||||||||||||
TrailStep |
int |
The trailing entry order follows the market in case the market moves in the direction opposite to that of the order (i.e. when the distance between the order and the current market price increases). 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 For example, if the value in the 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. The value is optional. By default, this value is If the value is specified, the order type in the Orders table will be |
||||||||||||
TimeInForce |
string |
The Time In Force value. Can be The value is optional. Entry orders are |
||||||||||||
ClientRate |
double |
The current price of the order instrument. The value is optional. It is used for logging purposes. |
||||||||||||
CustomID |
string |
The custom identifier of the order. This value will be populated into these columns of the trading tables:
The value is optional. |
You can also create a pair of stop and limit orders for the trade using the same command. Please refer to Attach Stop and/or Limit Orders to the Command for details.
Example: Create an Entry Stop order [hide]
public void PrepareParamsFromLoginRules(O2GLoginRules loginRules) { mParams = new OrderCreationParameters(); O2GResponseReaderFactory factory = mSession.getResponseReaderFactory(); if (factory == null) return; // Gets first account from login. O2GResponse accountsResponse = loginRules.getTableRefreshResponse(O2GTable.Accounts); O2GAccountsTableResponseReader accountsReader = factory.createAccountsTableReader(accountsResponse); O2GAccountRow account = accountsReader.getRow(0); // Store account id mParams.AccountID = account.AccountID; // Store base iAmount mParams.BaseAmount = account.BaseUnitSize; // Get offers for eur/usd O2GResponse offerResponse = loginRules.getTableRefreshResponse(O2GTable.Offers); O2GOffersTableResponseReader offersReader = factory.createOffersTableReader(offerResponse); for (int i = 0; i < offersReader.Count; i++) { O2GOfferRow offer = offersReader.getRow(i); if (string.Compare(offer.Instrument, "EUR/USD", true) == 0) { mParams.OfferID = offer.OfferID; mParams.Ask = offer.Ask; mParams.Bid = offer.Bid; mParams.PointSize = offer.PointSize; break; } } } public void PrepareParamsAndCallEntryStopOrder(string sOfferID, string sAccountID, int iAmount, double dPointSize, int iNumPoints, string sBuySell) { double dCurrentRate = 0; double dOrderRate = 0; if (sBuySell == Constants.Buy) { dCurrentRate = mParams.Ask; dOrderRate = dCurrentRate + dPointSize * iNumPoints; // The buy order dRate must be above the market. } else // BuySell = Constants.Sell { dCurrentRate = mParams.Bid; dOrderRate = dCurrentRate - dPointSize * iNumPoints; // The sell order dRate must be below the market. } CreateEntryStopOrder(sOfferID, sAccountID, iAmount, dOrderRate, sBuySell); } public void CreateEntryStopOrder(string sOfferID, string sAccountID, int iAmount, double dRate, string sBuySell) { O2GRequestFactory factory = mSession.getRequestFactory(); if (factory == null) return; O2GValueMap valuemap = factory.createValueMap(); valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder); valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.StopEntry); valuemap.setString(O2GRequestParamsEnum.AccountID, sAccountID); // The identifier of the account the order should be placed for. valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID); // The identifier of the instrument the order should be placed for. valuemap.setString(O2GRequestParamsEnum.BuySell, sBuySell); // The order direction (Constants.Buy for buy, Constants.Sell for sell) valuemap.setDouble(O2GRequestParamsEnum.Rate, dRate); // The dRate at which the order must be filled (above current dRate for Buy, bellow current dRate for Sell) valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount); // The quantity of the instrument to be bought or sold. valuemap.setString(O2GRequestParamsEnum.CustomID, "StopEntryOrder"); // The custom identifier of the order. O2GRequest request = factory.createOrderRequest(valuemap); mSession.sendRequest(request); // Store the request and set delete actions. After the order has been created, // delete it. mActions[request.RequestID] = Action.DeleteOrder; }