← Algo & Backtesting

Holding past the close: BTST, positional and overnight protection

An intraday strategy has a clean ending: the square-off. The moment you hold overnight, you take on a gap you cannot trade through and a margin you must keep funded. Algo has three tools for this, each for a different holding period.

Three holding periods

By default a strategy is intraday and is squared off at its exit time. Step 3C changes that in one of two ways, and Step 3D adds protection on top:

BTST and STBT

Set a Start Time for today’s entry and an Exit Time for the next trading day. With both set, the strategy is held across the close and the exit time rolls to the next session. The BTST and STBT templates use 15:15 IST entry and 09:20 IST exit. Entry and exit conditions remain available but are optional.

In a backtest the entry day runs to the close with no same-day square-off, the position carries the overnight gap at its strikes, and it exits at your exit time the next session. The gap lands in the P&L as it would live.

Positional hold and rollover

Tick Positional — hold across days and there is no daily square-off. The position stays fully managed every session: leg stops, targets and trails, basket limits, exit conditions and adjustments. Each leg closes on its own expiry day at the exit time — 15:25 IST by default, 23:25 for MCX — so in a calendar the near leg closes and the far leg keeps running.

Auto-rollover carries a held position to the next expiry instead of closing it: a set number of days before expiry, at a set time, the run is squared off and relaunched on the next expiry, entering immediately without waiting for the entry condition again. On expiry day the roll runs no later than five minutes before the exit time. Legs not in the expiring series stay where they are, futures legs move to the next month, and a strategy that is still flat is not rolled.

Step 3C Positional hold switched on, with the What this means box describing how the basket is carried across days.
Step 3C Positional hold switched on, with the What this means box describing how the basket is carried across days.
Step 5 Contract Rollover opened: Auto-rollover ticked, with days before expiry and the IST roll time.
Step 5 Contract Rollover opened: Auto-rollover ticked, with days before expiry and the IST roll time.

Overnight Protection

Overnight Protection buys a protective option against every open short option leg at the apply time and sells it at the remove time next session. Defaults are 15:20 and 09:20 IST. The hedge is the same expiry and quantity as the short leg and always further out of the money. It needs NRML.

Strike methodPicks the hedge…
Strike distanceN strikes beyond the short (default 3; 1–20).
Premium closest to ₹Whose premium is nearest a ₹ target.
Delta closest toWhose |delta| is nearest a target (0.01–0.90).
Max OI strikeWith the highest open interest beyond the short.
Straddle-width ×A multiple (0.1–5) of the ATM straddle premium away.
Underlying % awayNearest spot ± X% (0.1–25).

An extra ± strikes offset (−20 to +20) applies after the method, clamped so the hedge stays beyond the short. If a short leg exits overnight, its hedge goes with it. Hedge P&L is part of the strategy MTM, weekends and holidays simply wait for the next session, and the hedge set is rebuilt from the order record after a restart.

Step 3D Overnight Protection fields: strike rule, strikes away, apply time 15:20 and remove time 09:20, shown switched off.
Step 3D Overnight Protection fields: strike rule, strikes away, apply time 15:20 and remove time 09:20, shown switched off.

A worked example

You hold a short NIFTY 25,000 CE and 25,000 PE on NRML. Method: strike distance 3, on a 50-point step. At 15:20 the engine buys the 25,150 CE and the 24,850 PE.

Your overnight worst case is now capped near the width: 150 points per side, less the net credit, instead of an open-ended gap. At 09:20 both hedges are sold. If the market gapped up, the CE hedge’s gain offsets part of the short call’s loss; on a flat open you paid the hedges’ time value and spread for the insurance. Margin effects are explained in SPAN margin explained.

Common mistakes

Overnight Protection is simulated in backtests of BTST/STBT strategies, using the same six methods, so the report shows what the hedges cost or saved on each gap.

Where to find it

  1. In Algo & Backtest, open Step 3C and set BTST/STBT times or tick Positional.
  2. For rollover, enable it in Step 5 and set days before expiry and the time.
  3. Open Step 3D to enable Overnight Protection, pick a method and the apply/remove times.
  4. Set Product to NRML in Step 6.

Common questions

Can I automate a BTST options trade?

Yes. Set a start time today and an exit time for the next trading day, for example 15:15 and 09:20 IST, and the strategy holds across the close.

What happens to a positional strategy at expiry?

Each leg closes on its own expiry day at the exit time, 15:25 IST by default. With auto-rollover on, the position is moved to the next expiry instead.

Why does overnight protection need NRML?

MIS positions are squared off intraday, so there is nothing to carry overnight. Strategies that use it on MIS are refused at launch.

When are overnight hedges bought and sold?

By default they are bought at 15:20 IST and sold at 09:20 IST on the next trading day. Both times are editable.

Is overnight protection included in backtests?

Yes, for BTST and STBT strategies. Hedges are bought at the apply bar using the chosen method and sold at the remove bar.

More on Algo & Backtesting

More in Algo & Backtesting · App: Algo & Backtest · Definitions: glossary · All: every article