**order_type** Type of order. It can be one of the following MARKET refers to market order LIMIT refers to Limit Order SL refers to Stop Loss Limit SL-M refers to Stop Loss Market
How do I use it?
As of now, when I place the order, I pass “MARKET” value for Order_Type.
Do I need to again call the same method with now Ordertype == SL as the field for the same script?
How will system know this SL is for which order?
If I have two orders for script one as CNC and one has MIS, how will system know this SL is for which?
Thank you for contacting us. Here’s the response to your queries:
There’s no need for a separate method invocation. When submitting an SL MARKET order Just add the trigger_price in the same request, as detailed in our documentation. For an SL LIMIT order, though, you need to specify the price as well
The SL is associated with the specific stock and order_type, and the system monitors this internally.
CNC and MIS represent two distinct order categories. SL order designated for CNC applies only to CNC, while SL set for MIS is exclusively relevant to MIS orders. They are not interchangeable.
Could you please explain me with the above example on how I can place the stoploss order too while placing the purchase order?
Also, I would like to do following:
Trail the stoploss i.e. keep on modifying the stoploss programmatically as and when the LTP goes in my desired direction…
Have these SLs in place always. i.e. either they stay active until they are cancelled / expired. Or, I can create a new SL daily if that is not possible.
If you want a Stop Loss limit order, set the order_type to “SL” and specify the price field as the limit price.
Currently, our system doesn’t support trailing stop loss, but we’re actively working on this feature, which will be available soon. Please note that Stop Loss orders will remain active for one day and won’t continue until the next day. However, you can place a limit order on the following day. To address this limitation, we plan to enable GTT (Good Till Triggered) orders through the API, allowing for orders that remain valid until a specified condition is met or until you cancel them.
Thanks a lot for the details @Pradeep_Jaiswar. Ah understood now, sorry for my lack to knowledge on these types of orders. I have till now being doing direct Market buy and sell based on my code trail…
So, to summarize my understanding (please do correct me if I am wrong).
Instead of doing the “MARKET” order, I should be using SL/SL-M orders as these orders also support the BUY+StopLoss together.
If I am using SL-M, then “price” field is set to 0 so that the order is placed at the Market price
If I am using SL, then “price” field should contain the purchase price for the stock.
In both the cases, the “trigger_price” field is the Stop-loss price i.e. when the price drops/reaches to this price, the trade will be exited by the system.
The StopLoss order expires on the same the day. In this case, how do I place the stoploss order again? Do I need to use the Modify order in the next day and define the trigger_price? Any example will be really helpful.
Great to hear that my queries coincides with others too
On SL in the same order:
Yeah, my understanding is till now same that in the same BUY order the SL can be done. However, I am waiting for confirmation from @Pradeep_Jaiswar on my previous message. I might give it a short in the live market tomorrow to see how it works.
On Seperate SL Order:
Since you mentioned that you are placing the seperate SL-L order, I wanted to understand how do you do that. I mean, how do you define that the SL order you are placing is for which previous script/order? Do you have any reference log something like below / or if you could modify it to help me understand.
Your understanding is correct regarding the “On SL in the same order.”
The “On Separate SL Order” refers to a distinct limit order for the opposite transaction. If the initial transaction were a buy, this would be a sell, and vice versa.
To maintain a stop loss (SL) for the coming days, you can use a Good-Til-Triggered (GTT) order if the price falls below or rises above a certain level. This feature is not yet accessible through the API (available on the web and mobile), but it is currently in development and will be available shortly. In the meantime, you’ll need to set a separate SL order each day as previously mentioned.
I have 1 concern over your point no. 4.
“In both the cases, the “trigger_price” field is the Stop-loss price i.e. when the price drops/reaches to this price, the trade will be exited by the system.” → here the higlighted part should be entered and not exited
this again raise 1 concerns that how will we be able to set both entry and exit criteria in a single order
Placing a buy order without any SL - This action will execute the stock purchase at the current market price.
Placing sell order separately - This action will complete the stock sale at the market price. However, it’s important to note a correction: You should set the order type to LIMIT and specify a price. This ensures that your sell order is carried out when the set price is reached instead of at the current market price.
Second Column:
Points 1 and 2 are accurate. Regarding the third point, change the order type to SL and define the price at which the stock should be purchased. In this case, the trigger price will be the price you intend to sell.
Third Column:
For guidance on this point, refer to the response provided in the second column for the third point.
I recommend familiarizing yourself with market orders, limit orders, and stop-loss orders, and then experimenting with them. By trying these out, you’ll gain a clearer understanding of how they work.
Thank you @Pradeep_Jaiswar for the very elaborative answer. I understood it overall now. I will do further research to understand with the concepts on these.
Gave exact parameters and got a response from the API as below:-
{'status': 'error', 'errors': [{'errorCode': 'UDAPI1037', 'message': 'Trigger price should be less than limit price', 'propertyPath': 'price, trigger_price', 'invalidValue': [699.0, 700.0], 'error_code': 'UDAPI1037', 'property_path': 'price, trigger_price', 'invalid_value': [699.0, 700.0]}]}
What I conlclude from this is we cannot use “SL” or “SL-M” to set a Stop Loss.
these order type are single leg order only…that means can only be used for entering the trade and cannot be used to set exit criteria.
Inorder to set Stop Loss we need to use CO/OCO order only.
So for
1] Scenario #2 :- The Stock will be bought at CMP only when the LTP crosses the trigger price .
2] Scenario #3 :- With the current params it will throw abpve error. but if we change the trigger price to 699 and price to 700 then below scenario will happen.
The Stock will be bought only when the LTP crosses the trigger price of 699 and the price at which the order will execute will be between the range of 699.00 to 700.00.
if there is any seller available between this range then at that price only the trade will happen.