Stop loss vs trailing stop vs time exit in a backtest
How fixed stops, trailing stops, take-profits and exit-before-expiry rules behave on the same NIFTY option trade, and why they fill worse than the trigger.
- By
- Veloce team
- Published
- Reading time
- 9 min read
On this page
A stop loss closes a position once its loss from entry reaches a set amount. A trailing stop closes it once it gives back a set amount from its best profit, so it only moves in your favour. A time-based exit closes it because of the clock or calendar, such as a set number of days before expiry, whatever the price. On the same trade they can produce very different results. In the example below, one short NIFTY call ends anywhere from a ₹1,690 profit to a ₹2,600 loss depending on the rule. In every case the exit fills at the next candle’s open, not at the trigger price. This article shows how each rule behaves in a backtest and how to compare them fairly.
The three families of exit
| Exit | Fires when | Protects against | Typical weakness |
|---|---|---|---|
| Stop loss | Loss from entry reaches an amount | A trade going badly wrong | Gives back all open profit before it fires |
| Trailing stop | P&L falls an amount below its best level | Turning a winner into a loser | Shaken out by normal swings if too tight |
| Take profit | Profit reaches an amount | Holding too long for the last rupee | Caps the best trades |
| Time exit | A time or calendar condition is met | Expiry-day risk, overnight gaps | Exits regardless of how the trade is doing |
Take profit is not a stop, but it is part of the same decision and is tested alongside the others, so it is included here.
How exits are evaluated in a backtest
The details of evaluation matter more than the choice of rule. In Veloce:
- Exits are checked at every candle close, after the strategy has made its decision and before risk limits. Every open position’s P&L is computed from that close.
- The first rule that is met wins. If a stop and a trailing stop both trigger on the same candle, the one listed first is recorded as the reason.
- The exit order fills at the next candle’s open, plus any slippage you have configured. It never fills at the trigger level, and never at a price the strategy has already seen. This is the same no-lookahead rule that applies to every order (see slippage in backtests).
- Charges apply to the exit order like any other. A strategy that exits often pays more.
Amounts can be fixed rupees or relative to the position: a share of the credit received (for positions opened for a credit), a share of the premium paid (for debits), or a share of the best profit reached (for trailing). A trailing stop can also wait for activation: it only starts trailing once profit has reached a threshold.
One trade, five outcomes
Sell one lot (65 units) of a NIFTY weekly call at ₹100. The credit is ₹6,500. Here are twelve 15-minute candles of the option’s premium. A short position profits when the premium falls.
| Candle | Open | Close | P&L at close (₹) |
|---|---|---|---|
| 1 | 100 | 96 | +260 |
| 2 | 96 | 90 | +650 |
| 3 | 90 | 84 | +1,040 |
| 4 | 84 | 78 | +1,430 |
| 5 | 78 | 74 | +1,690 (best) |
| 6 | 74 | 80 | +1,300 |
| 7 | 80 | 86 | +910 |
| 8 | 86 | 95 | +325 |
| 9 | 95 | 108 | −520 |
| 10 | 108 | 121 | −1,365 |
| 11 | 128 | 134 | −2,210 |
| 12 | 134 | 140 | −2,600 |
Candle 11 opens at ₹128, ₹7 above candle 10’s close. That gap is what fast markets look like, even on 15-minute candles. Now apply each rule to the same path. Every result below is what Veloce’s exit rules produce on these candles:
| Rule | Fires after candle | P&L when it fires | Fills at | Exit P&L (₹) |
|---|---|---|---|---|
| Take profit at 25% of credit (₹1,625) | 5 | +1,690 | 74 (candle 6 open) | +1,690 |
| Trailing stop ₹650, active after ₹1,000 profit | 7 | +910 | 86 (candle 8 open) | +910 |
| Trailing stop 50% of best profit, active after ₹1,000 | 8 | +325 | 95 (candle 9 open) | +325 |
| Stop loss ₹1,300 (20% of credit) | 10 | −1,365 | 128 (candle 11 open) | −1,820 |
| No exit, or trailing stop active only after ₹2,000 | none | −2,600 at candle 12 |
What the table shows
- The stop loss filled ₹520 worse than its own level. It was set at ₹1,300. The candle that crossed it closed at −₹1,365, and the next candle opened at ₹128, so the exit filled at −₹1,820. That is 40% more loss than the stop “allowed”. The same thing happens live with a stop-loss market order in a fast market. Size positions on the loss you might really take, not the stop level.
- The trailing stops kept part of the profit. Both armed once profit passed ₹1,000. The ₹650 trail fired first and kept ₹910. The 50%-of-best trail allowed ₹845 of giveback and kept ₹325. A tighter trail keeps more of a reversal like this one, and gets shaken out more often in a choppy market that later recovers.
- An activation threshold that is never reached means no protection. The trail that only activates after ₹2,000 of profit never armed, because the best profit was ₹1,690. With no other exit, the trade lost ₹2,600. Combine a trailing stop with a fixed stop so there is always a floor.
- Take profit did best on this path, and only on this path. It would have capped a trade where the premium kept falling to ₹20 at the same ₹1,690.
One path proves nothing about which rule is better. What it shows is the mechanism: where each rule fires and why the fill differs from the trigger. To decide between rules you need hundreds of trades.
Long options and futures: the same rules, mirrored
The rules work on P&L, so they behave the same way for long positions and for futures. Only the scale changes.
- Long options. A stop at a share of the premium paid fits naturally: buy a NIFTY call at ₹120 (₹7,800 per lot) with a stop at 30% of cost, and the rule fires once the position is down ₹2,340. A long option can never lose more than its premium, so the stop is a choice to keep part of the premium, not a cap on unlimited risk.
- Futures. On MCX GOLD MINI, each ₹1 move in the price per 10 grams is ₹10 per lot. A ₹3,000 stop is a 300-rupee move in the quoted price, about 0.23% at ₹1,28,000. Gold can move that far within one candle on a busy day, and the session runs until late evening, so gap risk between candles is real. The gold futures article has the contract details.
For every instrument, check the stop distance against the typical range of one candle at the resolution you test. If the stop is smaller than an ordinary candle’s range, it will fire on noise.
Time-based exits
Time-based exits close positions because of the clock, not the price. There are two common kinds:
- Intraday square-off at a fixed time, such as 15:15 for NSE options or 23:15 for MCX gold. It removes overnight risk entirely. In Veloce this is part of the strategy’s plan, for example its last entry time and square-off time.
- Exit before expiry, a set number of days before the contract expires. For option sellers it avoids the highest-gamma hours, the extra 2% expiry-day margin that SEBI introduced in November 2024, and the question of exercise STT on in-the-money long legs.
The calendar-day trap
Veloce’s exit-before-expiry rule counts calendar days: it fires when the days between today and expiry are at most the setting. With weekly Tuesday expiries, a setting of 1 fires on Monday. Holidays break that pattern.
Tuesday 24 November 2026 is an exchange holiday, so the NIFTY weekly expires on Monday 23 November:
| Setting | Thu 19 Nov (4 days left) | Fri 20 Nov (3 days left) | Mon 23 Nov (expiry) |
|---|---|---|---|
| 1 day before | stays open | stays open | exits on expiry day |
| 3 days before | stays open | exits |
With the 1-day setting, the rule first fires on expiry day itself, because Sunday is the only day exactly one calendar day before. To always be out by the last trading day before expiry, use a setting that covers weekends and holidays (3 for Tuesday expiries), or test both and compare. The expiry calendar lists the holiday-shifted dates.
Exits on spreads: per leg or per position
A rule can watch each contract on its own, or every leg on the same underlying and expiry together:
- Per leg suits single-leg strategies and futures.
- Per position suits spreads, strangles and condors. The stop watches combined P&L, and when it fires every leg closes together. The short legs are listed first, so the closing orders buy back the shorts before selling the hedges.
A per-leg stop on an iron condor can buy back a losing short call while leaving its long call open. The position is then a long call plus the put side, which is a different trade from the one you tested. Unless that is the intent, group by position.
Amounts relative to the position adapt to it. A stop at 50% of credit on a condor that collected ₹4,745 is ₹2,372.50. On one that collected ₹2,000 it is ₹1,000. That keeps a rule meaningful as premiums change with volatility.
How to compare exit rules fairly
- Hold entries constant. Same strategy, same entry rules, same period. Only the exit changes.
- Include charges and slippage. Tight trailing stops trade more, and each exit is an order. See F&O charges explained for the cost per order.
- Use one-minute data. Coarser candles check less often and fire later. A stop checked on 15-minute closes can blow through its level by much more than one checked every minute.
- Compare net P&L, maximum drawdown and the worst single trade. A stop that lowers average P&L slightly but halves the worst trade may be worth it. See max drawdown and position sizing.
- Sweep, then check. Try a grid of distances, such as stops at 20%, 50% and 100% of credit, and trails at 25% and 50% of best profit. Rank them on one period and rerun the best on a later one. If the ranking flips, the rule is fitting noise. Veloce’s sweeps do this in one command.
- Read the exit reasons. Every Veloce trade records why it closed: stop loss, trailing stop, take profit, before expiry, square-off or signal. If 80% of exits are trailing stops that fire within a few candles, the trail is too tight for the instrument’s normal noise.
Common mistakes
- Testing on closes and assuming fills at the stop. That removes the gap risk in the example above, which is often the largest loss a short-option strategy takes.
- Optimising the stop distance alone. A stop that looks best in-sample is usually the one that happened to dodge the period’s two worst days.
- Forgetting that exits are orders. An option that has not traded for a few minutes cannot be exited until it does. The exit fills at the next candle that exists for that contract.
The risk and exits page lists every rule, amount type and grouping Veloce supports.
Try it in Veloce
Run the same NIFTY or SENSEX option strategy three times: with a stop loss, with a trailing stop, and with both plus an exit three days before expiry. Compare the exit reasons and the drawdown. Create a free account and pick a strategy from the library.
Frequently asked questions
- Is a trailing stop better than a fixed stop loss?
- Neither is better in general. A fixed stop caps the loss from entry. A trailing stop protects profit already made but can exit early in choppy markets. Test both on the same entries, with charges and next-candle fills, and compare net P&L and drawdown over a period you did not tune on.
- Why did my stop loss exit at a bigger loss than the stop?
- A stop is a trigger, not a guaranteed price. In a backtest that checks candle closes, the exit order fills at the next candle's open, and a fast market or a gap moves that price past the stop. The same happens live with a stop-loss market order.
- How do you set a stop loss for option selling?
- A common approach is a share of the premium collected, such as 20% to 100% of the credit, or a fixed rupee loss per position. Whatever you choose, size the position so the stop's loss, plus a margin for slippage, is a small share of equity.
- What is a time-based exit?
- An exit that closes a position because of the clock or calendar rather than price, such as squaring off at a fixed time of day or closing a set number of days before expiry.
- Should the stop apply to each leg or the whole spread?
- For spreads and condors it is usually the whole position. A per-leg stop can close the short leg of a spread and leave the long leg alone, which changes the trade's risk. Veloce can group legs by underlying and expiry so a rule watches the combined P&L.
Sources
- NSE: trading holidaysnseindia.com, accessed
- SEBI circular SEBI/HO/MRD/TPD-1/P/CIR/2025/76: final settlement day (expiry day) for equity derivatives contractssebi.gov.in, accessed
- SEBI circular SEBI/HO/MRD/TPD-1/P/CIR/2024/132: measures to strengthen the equity index derivatives frameworksebi.gov.in, accessed