# How to place stop loss for MTM?

**URL:** https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843
**Category:** Trading
**Created:** [August 31, 2020, 1:10am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843 "2020-08-31T01:10:16Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Chet1](https://tradingqna.com/user_avatar/tradingqna.com/chet1/32/16427_2.png) [@Chet1](https://tradingqna.com/u/Chet1)
#### Post date: [August 31, 2020, 1:10am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/1 "2020-08-31T01:10:16Z")

</div>

Stop loss orders can be placed for a given scrip but not for overall open positions.

Is there is possibility to do it to limit overall loss or overall profit for the portfolio?

---

<div class="post-metadata">

### Author: ![retipser\_j](https://tradingqna.com/user_avatar/tradingqna.com/retipser_j/32/54503_2.png) [@retipser\_j](https://tradingqna.com/u/retipser_j)
#### Post date: [April 29, 2022, 5:41am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/2 "2022-04-29T05:41:36Z")

</div>

With an api\_algo you can create a condition based exit on pnl

---

<div class="post-metadata">

### Author: ![Nidal](https://tradingqna.com/user_avatar/tradingqna.com/nidal/32/36777_2.png) [@Nidal](https://tradingqna.com/u/Nidal)
#### Post date: [April 29, 2022, 3:57pm UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/3 "2022-04-29T15:57:28Z")

</div>

Can you elaborate it more in detail?

---

<div class="post-metadata">

### Author: ![Yash\_Chhabra1](https://tradingqna.com/user_avatar/tradingqna.com/yash_chhabra1/32/18896_2.png) [@Yash\_Chhabra1](https://tradingqna.com/u/Yash_Chhabra1)
#### Post date: [September 15, 2023, 8:29am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/4 "2023-09-15T08:29:16Z")

</div>

Can someone please advise how to put stoploss for overall MTM basis.  
Eg I want to exit my positions when my overall MTM loss on my open positions is 10k  
& similarly I want to exit all open positions once my overall p&l for the open positions is 20K

---

<div class="post-metadata">

### Author: ![buzzsubash](https://tradingqna.com/user_avatar/tradingqna.com/buzzsubash/32/34082_2.png) [@buzzsubash](https://tradingqna.com/u/buzzsubash)
#### Post date: [September 15, 2023, 11:52am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/5 "2023-09-15T11:52:06Z")

</div>

MTM based square off is something no brokers provide.

We will have to build a custom conditions/logic based algorithm using zerodha’s kite api, in python, php, C language etc.

The code is to be developed based on fetching the existing positions, check order book for executed orders, fetch buy price, sell price, points difference between them to assume in profit/loss, filter out failed orders due to broker error, exchange error, margin error etc, exception handling due to delay of execution of our square off orders, slippage etc. On top of if, freak trades, a hidden ghost.

It is literally a complex piece of code. It took me more than a month to develop and run it through multiple scenarios to make it bug proof. I did things in python and I thought I cracked it, later after a 5 months of gap, a freak trade screwed up all the logics, which was later fixed.

Please DM if you need, ofcourse there is a price for it, and it’s not cheap.

---

<div class="post-metadata">

### Author: ![Yash\_Chhabra1](https://tradingqna.com/user_avatar/tradingqna.com/yash_chhabra1/32/18896_2.png) [@Yash\_Chhabra1](https://tradingqna.com/u/Yash_Chhabra1)
#### Post date: [September 16, 2023, 9:11am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/6 "2023-09-16T09:11:55Z")

</div>

Understood, thanks!  
I use Hdfc securities, can your code be implemented for hdfcsec?

---

<div class="post-metadata">

### Author: ![santhanakrishnan25](https://tradingqna.com/user_avatar/tradingqna.com/santhanakrishnan25/32/69985_2.png) [@santhanakrishnan25](https://tradingqna.com/u/santhanakrishnan25)
#### Post date: [October 6, 2023, 1:02am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/7 "2023-10-06T01:02:26Z")

</div>

This should be pretty easy. kite.positions api will return enough data. just use chatgpt and get the api to reverse open positions. dont waste money!!

---

<div class="post-metadata">

### Author: ![Pramodsinha](https://tradingqna.com/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@Pramodsinha](https://tradingqna.com/u/Pramodsinha)
#### Post date: [April 4, 2024, 8:17am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/8 "2024-04-04T08:17:40Z")

</div>

What would be the estimate cost for this custom code, I am interested - How can I contact you

---

<div class="post-metadata">

### Author: ![trader.alpha](https://tradingqna.com/user_avatar/tradingqna.com/trader.alpha/32/18059_2.png) [@trader.alpha](https://tradingqna.com/u/trader.alpha)
#### Post date: [April 13, 2024, 8:47am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/9 "2024-04-13T08:47:27Z")

</div>

i think zerodha has something called kill switch

---

<div class="post-metadata">

### Author: ![paekut](https://tradingqna.com/user_avatar/tradingqna.com/paekut/32/21368_2.png) [@paekut](https://tradingqna.com/u/paekut)
#### Post date: [April 23, 2024, 5:51am UTC](https://tradingqna.com/t/how-to-place-stop-loss-for-mtm/88843/10 "2024-04-23T05:51:07Z")

</div>

Any update from Zerodha?

Dire need of portfolio level stoploss which automatically exits all open positions as soon as x amount of loss is hit.
