Smart Trail
This API allows you to place a trailing stop-loss order whose stop price follows the market as it moves in your favour.
USE CASE
Protect an open position with a stop-loss that moves with the price to lock in gains.
Note
- For sell orders, the stop price moves up as the price rises.
- For buy orders, the stop price moves down as the price falls.
- The order is triggered when the market price hits the trailing stop price.
- You can optionally set a target price to book profits automatically.
- Supports both Limit and Market (MPP) order types for execution.
- Supports only NSE & BSE segments, click here to check allowed and not allowed segments.
Details
- A Smart Trail Order is a trailing stop-loss that automatically adjusts the stop price as the market moves in your favour. The stop price trails the market by a specified jump price.
jump_diffis how far the stop trails. It must be at least 0.2 and more than 20 times the tick size.stopPricemust be greater than 0.productTypecan be CNC, MARGIN, INTRADAY or MTF.- For a Limit order (
orderType1) sendlimitPrice. For a Market order (orderType2) leavelimitPriceout or 0. - For a Market order, a buy
stopPricemust be at or above LTP, and a sellstopPriceat or below LTP. target_priceis optional. If sent, it must be above LTP for a sell order and below LTP for a buy order.qtymust be 1 to 999999 and a multiple of the lot size.mppmust be 0 to 3 or -1.- Smart orders can be created only on trading days (not special trading days), from 8:00 AM and within regular trading hours. The limit is 100 smart orders per day.
- Rate limits differ between the Standard and Prime plans. See Plans & rate limits.
Request Attributes
Validations & Error Messages
| Attribute | Validation Rule | Error Message |
|---|---|---|
symbol | Must be a valid trading symbol | "The symbol entered is invalid." |
symbol | Must be allowed for smart orders | "The selected symbol is not allowed for placing smart orders. Please try again with a different symbol." |
symbol | Must be allowed for this segment | "The smart order not allowed for this segment" |
side | Must be 1 or -1 | "The input details entered is invalid." |
qty | Min: 1, Max: 999999, must be multiple of lot size | "Quantity should be multiple of min lot size." |
productType | Must be one of: CNC, MARGIN, INTRADAY, MTF | "productType must be one of the following: CNC, MARGIN, INTRADAY, MTF" |
orderType | Must be 1 or 2 | "orderType must be one of the following: 1, 2" |
stopPrice | Min: 0, cannot be 0 for placing order | "Stop Price is required to place orders." |
jump_diff | Min: 0.2, must be > 20× tick size | "The jump price must be more than 20 times the tick size." |
limitPrice (buy) | If orderType=1, must be < stopPrice | "For buy orders, the stop price must be lower than the limit price." |
limitPrice (sell) | If orderType=1, must be > stopPrice | "For sell orders, the stop price must be higher than the limit price." |
target_price (sell) | If provided (>0), must be > current LTP | "The target price must be greater than the last traded price for sell orders." |
target_price (buy) | If provided (>0), must be < current LTP | "The target price must be lesser than the last traded price for buy orders." |
mpp | If provided (>0), must be 0-3 or -1 | "MPP must be either -1 or a value between 0 to 3% (0 to 3)." |
limitPrice | If orderType=2 (Market), limitPrice must be 0 / not provided | "Limit price is not required." |
stopPrice (buy, orderType=2) | Must be >= current LTP | "For buy orders, the stop price must be greater than the last traded price." |
stopPrice (sell, orderType=2) | Must be <= current LTP | "For sell orders, the stop price must be less than the last traded price." |
flowtype | Must be a valid smart order type | "The smart order specified in the URL path is not recognized." |
| User | Must not be banned for smart orders | "You are banned for smart order. Please contact support" |
| Trading day | Must not be market-closed day | "You can't create smart orders on market-closed day" |
| Trading day | Smart orders not allowed on special trading day | "Smart orders are not allowed on special trading day" |
| Trading hours | Must not be after market hours | "Smart orders cannot be created after market hours." |
| Trading hours | Must not be before 8:00 AM | "Smart orders are not allowed to be created before 8:00 AM." |
| Trading hours | Must be within regular trading hours | "You can't place a smart order outside regular trading hours" |
| Daily limit | Max 100 smart orders/day | "You have exceeded the maximum limit of creating 100 smart orders for the day." |
Response Attributes
| Attribute | Data Type | Description |
|---|---|---|
code | int | Status code: 200 indicates success; negative values indicate errors. |
message | string | Descriptive message — e.g., "Request sent successfully to place smart order." or error reason. |
s | string | "ok" for success, "error" for failure. |
id | string | Unique identifier for the placed smart order (returned only on success). |
Last updated on