← Algo & Backtesting

Execution settings: how the orders actually go out

The same strategy can behave very differently depending on how its orders are sent. Selling the short legs before the hedges fill, a market order into a thin book, or a half-filled condor left running are execution problems, not strategy problems. Step 6 is where they are decided.

Why execution settings matter

A backtest fills at bar prices. A live run meets real order books, rejections and partial fills. Step 6 is the bridge: it decides the order legs go in, what happens when one fails, what price you are willing to pay, and on which days the strategy runs at all.

Leg order and failure policy

SettingOptions
Legs Executionbuy_first (default): BUY legs first, then SELL legs. parallel: all together. sequential: one after another.
Between hedge and short legsIn buy_first: fire the shorts immediately, wait for the hedge fills, or wait for fills plus 1–10 seconds.
If Leg Failscancel_all (default): unwind the legs already placed. keep_placed: continue with a partial basket. retry_failed: retry up to Max Retries, then fall back to cancel_all.
Strike ReferenceSpot, current-month futures, or synthetic futures from the chain — what counts as ATM.

buy_first with “wait for fills” means an iron condor is never even briefly a naked short, and the hedge benefit to margin is in place before the shorts go out. See SPAN margin explained for why that matters.

Step 6 Order sequencing and failure policy: legs execution, strike reference, hedge timing, if-leg-fails policy and max retries.
Step 6 Order sequencing and failure policy: legs execution, strike reference, hedge timing, if-leg-fails policy and max retries.

Order types and market protection

Entry and exit each have an order type — Market, Limit or Mkt Protect — and a buffer %.

A plain market order never leaves the platform. Every market order is sent as a marketable limit at LTP plus the buffer for a BUY or minus it for a SELL, rounded to the contract’s tick. If no buffer is set, a 3% band is used. A market order with no reference price is refused with the reason rather than sent blind.

Limit-order chase, when on, re-prices an unfilled limit toward the LTP after the chosen number of seconds, by the chase buffer %, and if it is still unfilled converts it to a protected market order at the current LTP.

Product is NRML (carry), MIS (intraday) or CNC (delivery). Validity is DAY or IOC, where IOC fills what is available immediately and cancels the rest.

Step 6 Order Execution section: entry and exit order types with buffers, limit-order chase, product and validity.
Step 6 Order Execution section: entry and exit order types with buffers, limit-order chase, product and validity.

Guards and run filters

Independently of these, a strategy does not start on exchange holidays or weekends.

A worked example

An iron condor with buy_first and “wait for fills”, entry type Mkt Protect, buffer 1%.

  1. The two wing BUY orders go out first. A wing with LTP ₹12.40 is sent as a limit at 12.40 × 1.01 = 12.524, rounded up to the ₹0.05 tick: ₹12.55.
  2. Once both wings are confirmed filled, the two SELL legs go out. A short leg at LTP ₹98.00 is sent at 98 × 0.99 = 97.02, rounded down to the tick: ₹97.00.
  3. If one wing is rejected and the policy is cancel_all, the filled wing is unwound and the shorts are never sent.

(Illustrative prices.)

Common mistakes

Placing API orders from a broker account also needs a registered static IP; see static IP for API trading.

Where to find it

  1. In Algo & Backtest, open Step 6 of the builder.
  2. Set Legs Execution, the hedge timing and If Leg Fails.
  3. Choose entry and exit order types and buffers, product and validity.
  4. Pick Run On Days or a DTE filter, then save.

Common questions

Does Algo send market orders to the broker?

No plain market orders. Every market order is converted to a limit at LTP plus or minus a protection buffer, 3% if none is set, rounded to the tick.

What does buy first mean in leg execution?

The BUY legs, usually hedges, are placed first and the SELL legs after them, optionally only once the BUY legs are confirmed filled.

What happens if one leg of my strategy is rejected?

With cancel_all, the default, the legs already placed are unwound. You can instead keep the partial basket or retry failed legs a set number of times.

How do I run a strategy only on expiry day?

Choose the DTE filter in Step 6, discrete mode, and select 0. DTE counts trading days, with expiry day as 0.

Can I limit how many lots a strategy trades?

Yes. Max Lots caps total quantity across all legs; a strategy that exceeds it is refused at launch.

More on Algo & Backtesting

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