← Algo & Backtesting

Re-entry and on-hit actions

A stop loss answers one question — when to get out — and leaves the next one open: what now? Re-sell? Hedge? Protect the other side? On-hit actions let a strategy answer that in advance, instead of you deciding under pressure.

Two decisions on every hit

When a leg’s stop or target rung fires, Algo asks two things: what happens to this leg, and what happens next.

For the leg itself you choose close this leg (the default), close this strategy (square off every open leg), or no action on this leg — the rung then acts purely as a trigger for the follow-up.

The follow-up is the on-hit action. Separating the two is what lets one stop both close a leg and wake a hedge.

The follow-up actions

ActionWhat it does
re-execute legPlaces a fresh entry for the same leg, up to N times. From a ladder rung, only that rung’s quantity is re-entered.
re-enter at original pricePlaces a LIMIT order at the leg’s original entry price, so it fills only if price returns there. Capped at N times.
re-execute strategySquares off every leg and starts a fresh copy of the strategy at current market, capped at N times, with an optional wait.
execute other legFires another leg of the strategy, usually one marked Idle, with an optional delay.
close all losing / profitable legsCloses every other open leg that is currently in loss, or in profit.
close all CE buys / CE sells / PE buys / PE sellsCloses legs by option type and side.
move SL to cost on profitable legsFor every other leg in profit, collapses its stop ladder into a single breakeven stop.
execute other strategyStarts a saved portfolio as a follow-up, with an optional delay.

On a target rung you can also add quantity to the same leg. Treat that like averaging: it enlarges a position the market has already moved on, so pair it with a hard basket stop.

A short strangle leg's Stoploss tab: a 50% premium stop that closes the leg, then re-executes it up to 2 times with a 300-second wait.
A short strangle leg's Stoploss tab: a 50% premium stop that closes the leg, then re-executes it up to 2 times with a 300-second wait.

Idle legs and hedge legs

Two checkboxes on each leg row make the actions more useful.

Idle means the leg does not fire at entry. It sits dormant until another leg’s action executes it. The classic use: a short call with a bought call marked Idle; if the short call’s stop hits, the action fires the wing as an emergency hedge.

Hedge marks a protective BUY leg. Hedge legs are left out of move-to-cost and close last when the strategy flattens, so the short legs are never briefly naked during a square-off.

A worked example

A short strangle: sell the 24,800 PE and the 25,200 CE at ₹60 each, 1 lot of 75, 50% stops (₹90). The CE stop is set to close this leg then re-execute leg, N = 1. The PE target is set to close this leg then move SL to cost on profitable legs.

(Hypothetical prices. The point is the sequence, not the outcome.)

Limits worth knowing

Basket-level actions

The same kind of actions exist at basket level in Step 5, fired by a combined stop or target rather than one leg. That is where “close everything and start again” or “close only the short calls” is usually configured. See basket risk, and per-leg stops for what triggers the leg-level ones.

Where to find it

  1. In Algo & Backtest, open Step 4 and click ⚙ settings on a leg.
  2. In the Stoploss or Target tab, set the leg action and the follow-up action on a rung.
  3. Set N times and any wait for repeat actions.
  4. Tick Idle or Hedge on rows that should behave as described above.

Common questions

How do I re-enter a short straddle after a stop loss?

On the leg's stop rung choose close this leg and then re-execute leg, and set how many times it may repeat. To restart the whole basket instead, use re-execute strategy.

What is an idle leg?

A leg that does not enter with the strategy. It waits until another leg's on-hit action fires it, which is useful for a hedge that should exist only after a stop is hit.

What does move SL to cost do?

For every other open leg currently in profit, it replaces the stop ladder with a single stop at that leg's entry price, so a winning leg cannot turn into a loss.

Can re-entry loop forever on a choppy day?

No. Every repeat action has an N times cap, and chained strategies are depth-limited.

More on Algo & Backtesting

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