Place Bracket Order
Place a bracket order with a target, a stoploss and a trailing stoploss in one call.
https://apix.stocksdeveloper.in/trading/placeBracketOrder The Place Bracket Order call places a bracket order with a target, a stoploss and a trailing stoploss in one call. The same function is available in AmiBroker, MetaTrader, Excel, Java, C#, Python and HTTP REST. On success it returns an order id; on failure it returns an error message. Your broker must support bracket orders on our platform.
This call places a bracket order. It works only on brokers that offer bracket orders on their own platform, so availability changes from broker to broker. The simplest way to check is to place a small sample bracket order and see if it goes through; if you get an error, your broker may not support it — contact support or suggest it as a feature request and we will look into it. For related order types, see Place Cover Order and Place Advanced Order.
Code samples
HTTP
Example
curl https://apix.stocksdeveloper.in/trading/placeBracketOrder \
-H "api-key: <your-api-key>" \
-d "pseudoAccount=ACC_NAME" \
-d "exchange=<exchange>" \
-d "symbol=SBIN" \
-d "tradeType=BUY" \
-d "orderType=LIMIT" \
-d "quantity=10" \
-d "price=180.5" \
-d "triggerPrice=0" \
-d "target=5" \
-d "stoploss=2.5" \
-d "trailingStoploss=1"Response
{
"result":"200622000335719",
"error":null,
"message":null,
"status":true,
"commandId":"9b87532c-cade-49d3-8ace-76db7be63029"
}The response fields work as follows:
| Field | Meaning |
|---|---|
result | The order id given by your trading platform. |
status | true on success. On error, it is false and message holds the error text. |
commandId | Used to trace the activity on AutoTrader Web. |
Python
Signature
def place_bracket_order(self, pseudo_account, \
exchange, symbol, tradeType, orderType, \
quantity, price, triggerPrice,
target, stoploss, trailingStoploss=0.0):Example
response = autotrader.place_bracket_order( \
'XX1234', '<exchange>', 'WIPRO', 'SELL', 'LIMIT', \
1, 326.35, 0.0, 1, 1, 0)
if response.success():
print("Result: {0}".format(response.result))
else:
print("Message: {0}".format(response.message))Java
Signature
/**
* Places a bracket order.
*
* @param pseudoAccount pseudo account
* @param exchange exchange
* @param symbol symbol
* @param tradeType trade type
* @param orderType order type
* @param quantity quantity
* @param price price
* @param triggerPrice trigger price
* @param target target
* @param stoploss stoploss
* @param trailingStoploss trailing stoploss
* @return the order id given by your stock broker
*/
IOperationResponse<String> placeBracketOrder(
String pseudoAccount, String exchange, String symbol,
TradeType tradeType, OrderType orderType, int quantity,
float price, float triggerPrice, float target,
float stoploss, float trailingStoploss);Example
// Place a bracket order
final IOperationResponse<String> response = autotrader
.placeBracketOrder("ACC_NAME", "<exchange>", "SBIN",
TradeType.BUY, OrderType.LIMIT,
10, 180.5f, 0f, 5f, 2.5f, 1f);
// Read order id
String orderId = null;
if (response.success()) {
orderId = response.getResult();
} else {
final String errorMessage = response.getMessage();
}This places a bracket order into the trading account mapped to the passed pseudo account. The response object has a success() method, which returns true on successful execution. Use getResult() to read the order id given by your trading platform.
C#
Signature
/// <summary>
/// Places a bracket order. For more information, please see <a href=
/// "https://stocksdeveloper.in/documentation/api/place-bracket-order/">api
/// docs</a>.
/// </summary>
/// <param name="pseudoAccount"> pseudo account </param>
/// <param name="exchange"> exchange </param>
/// <param name="symbol"> symbol </param>
/// <param name="tradeType"> trade type </param>
/// <param name="orderType"> order type </param>
/// <param name="quantity"> quantity </param>
/// <param name="price"> price </param>
/// <param name="triggerPrice"> trigger price </param>
/// <param name="target"> target </param>
/// <param name="stoploss"> stoploss </param>
/// <param name="trailingStoploss"> trailing stoploss </param>
/// <returns> the order id given by your stock broker </returns>
IOperationResponse<String> PlaceBracketOrder(
string pseudoAccount, string exchange,
string symbol, TradeType tradeType,
OrderType orderType, int quantity,
float price, float triggerPrice, float target,
float stoploss, float trailingStoploss);Example
IOperationResponse<string> response =
autoTrader.PlaceBracketOrder("XX1234",
"<exchange>", "SBIN", TradeType.SELL,
OrderType.LIMIT, 3, 220f, 0, 2, 3, 0);
if(response.Success()) {
Console.WriteLine("Result: {0}", response.Result);
}
else {
Console.WriteLine("Message: {0}", response.Message);
}This places an order into the trading account mapped to the passed pseudo account. The response object has a Success() method, which returns true on successful execution. Use the Result property to read the order id given by your trading platform.
Excel
Signature
Public Function PlaceBracketOrder( _
PseudoAccount As String, _
Exchange As String, _
Symbol As String, _
TradeType As String, _
OrderType As String, _
Quantity As Integer, _
Price As Double, _
TriggerPrice As Double, _
Target As Double, _
Stoploss As Double, _
TrailingStoploss As Double) As StringExample
Dim OrderId As String
OrderId = PlaceBracketOrder("ACC_NAME", _
"<exchange>", "SBIN", "BUY", "LIMIT", 1, _
200.55, 0, 3, 2, 1)This places a bracket order with a target of 3/-, stoploss of 2/- and trailing stoploss of 1/-.
AmiBroker
Signature
function placeBracketOrder(account, exchange,
symbol, tradeType, orderType,
quantity, price, triggerPrice,
target, stoploss, trailingStoploss, validate)Example 1
orderId = placeBracketOrder(AT_ACCOUNT,
AT_EXCHANGE, AT_SYMBOL, "BUY",
"LIMIT", AT_QUANTITY, buyPrice,
defaultTriggerPrice(), 5, 3, 1, True);This places a Limit bracket order for the account, exchange and symbol chosen in chart parameters, with a target of 5/-, stoploss of 3/- and trailing stoploss of 1/-. Some variables used above are parameters defined by the AutoTrader library.
Example 2
// Apply your logic to calculate stoploss trigger price
stoplossTriggerPrice = buyPrice - 5;
// Place bracket order (Stoploss)
orderId = placeBracketOrder("ACC_NAME",
"<exchange>", "WIPRO", "BUY",
"STOP_LOSS", 15, buyPrice,
stoplossTriggerPrice, 5, 3, 1, True);This places a STOP_LOSS bracket order, so a triggerPrice is passed. Here the values are passed directly instead of using chart parameters.
MetaTrader
Signature
string placeBracketOrder(string account,
Exchange exchange, string symbol,
TradeType tradeType, OrderType orderType,
int quantity, double price,
double triggerPrice, double target,
double stoploss, double trailingStoploss,
bool validate)Example 1
string id = placeBracketOrder(AT_ACCOUNT,
AT_EXCHANGE, AT_SYMBOL, BUY, LIMIT, 1,
192, 0.0, 5, 3, 1, true);This places a Limit bracket order for the account, exchange and symbol chosen in chart parameters, with a target of 5/-, stoploss of 3/- and trailing stoploss of 1/-. Some variables used above are parameters defined by the MetaTrader library.
Example 2
// Apply your logic to calculate stoploss trigger price
stoplossTriggerPrice = buyPrice - 5;
// Place bracket order (Stoploss)
string id = placeBracketOrder(AT_ACCOUNT,
AT_EXCHANGE, "WIPRO", BUY, STOP_LOSS, 15,
buyPrice, stoplossTriggerPrice, 5, 3, 1, true);This places a STOP_LOSS bracket order, so a triggerPrice is passed.
Postman
Postman is a widely used tool for API testing. We provide a collection of all our APIs in Postman collection format. See the Postman collection guide to learn how to use it.
Parameters
| Parameter | Description |
|---|---|
| account | nickname of the broker account (also known as pseudo account) |
| exchange | instrument (stock/derivative) exchange |
| symbol | instrument (stock/derivative) symbol |
| tradeType | trade type |
| orderType | order type |
| quantity | quantity |
| price | order price |
| triggerPrice | trigger price |
| target | target for bracket order |
| stoploss | stoploss for bracket order |
| trailingStoploss | trailing stoploss for bracket order |
| validate | validate order (check for duplicate signals). Only applicable for AmiBroker and MetaTrader. |
Note on quantity: For derivatives on Indian stock exchanges, quantity should be a multiple of the lot size. For example, if a contract’s lot size is 15, then to buy or sell 1 lot you enter 15 quantity.
Return value
The call returns the order id given by your trading platform.
The call returns the library order id. The Desktop Client passes the request on to your broker.
Notes
Your broker must support bracket orders on our platform. Try placing a bracket order from our platform’s trading terminal first to confirm whether it is supported.
For related order types, see Place Cover Order, Place Advanced Order, and Place Regular Order.
Thanks for the feedback. Still stuck? Contact support.
Last updated 22 June 2026