Trading strategies to backtest: shipped, rule-based or written as specs
Start from one of eleven shipped strategies for NIFTY, BANK NIFTY and SENSEX options and MCX gold futures, write entry rules from 24 indicator series, or describe a whole strategy as data. Every one plugs into the same harness, with the same fills, charges, exits and risk limits.
Three ways to plug a strategy in
Pick a shipped strategy
Eleven strategies with tested defaults. Change any setting, or sweep several at once.
Write indicator rules
Name the indicators you need and compare them with the close, each other or a number.
Describe it as a spec
The whole strategy as data: entries, legs, exits, risk, day rules and costs, checked before it runs.
Market data
One-minute bars, checked as they arrive and resampled to your candle.
Expiries and contracts
Expiry calendars with holidays, and strikes picked from the closed candle.
Fills
Every order fills at the next bar’s open, never on a price already seen.
Costs
Brokerage, STT or CTT, exchange and SEBI fees, stamp duty, GST and slippage.
Exits
Stops, targets, trails and exits before expiry, checked on every bar.
Risk limits
Lot caps, cash, futures margin, loss at expiry and daily limits.
Portfolio
Positions in units, cash, cost basis and equity, in exact decimals.
Reports and runs
Calendar, equity, breakdowns and trades, with every run stored.
Plugs in
Your strategy
Reads closed candles and returns the position it wants, in signed lots. It never places an order or touches cash.
- A shipped strategy
- Your own indicator rules
- A strategy spec, written as data
Backtests today. Paper and live trading are coming soon.
Index options, selling premium
Iron condor
iron-condorOnce per expiry, at the entry time, sells a put and a call a set number of strikes either side of the at-the-money strike and buys wings further out.
- Candle
- 1 minute
- Defaults
- Entry 10:00Short strikes 4 steps outWings 4 steps widerAt least 5 days to expiry
- Exits
- Take profit at 50% of the credit, stop at 2× the credit, exit 1 day before expiry
Hedged straddle
straddle-sellerEach morning sells the at-the-money call and put and buys a call and a put a set number of strikes away, then closes everything at the square-off time.
- Candle
- 1 minute
- Defaults
- Entry 09:20Square-off 15:15Wings 4 steps outTrades on expiry day too
- Exits
- Each sold leg is bought back if it loses 30% of its premium
MACD credit spread
macd-sellerOn a MACD and 200-period trend signal, sells a put spread when bullish or a call spread when bearish, and flips the spread when the signal reverses.
- Candle
- 5 minutes
- Defaults
- MACD 12, 26, 9Trend 200Short strike 2 steps outWing 4 steps wider
- Exits
- Take profit at 50% of the credit, stop at 1× the credit, exit 1 day before expiry
Index options, buying on a signal
Moving average crossover
sma-buyerBuys a call when the fast simple moving average crosses above the slow one and a put when it crosses below, holding one contract at a time.
- Candle
- 3 minutes
- Defaults
- Fast 9, slow 21At-the-money strikeEntries 09:15 to 15:00Square-off 15:15
- Exits
- Opposite signal or square-off; optional stop, target and trailing stop
EMA crossover
ema-buyerThe same as the moving average crossover, on exponential moving averages.
- Candle
- 5 minutes
- Defaults
- Fast 9, slow 21At-the-money strikeEntries 09:15 to 15:00Square-off 15:15
- Exits
- Opposite signal or square-off; optional stop, target and trailing stop
MACD with a 200 trend filter
macd-buyerBuys calls when the MACD histogram turns positive above a 200-period average, and puts when it turns negative below it.
- Candle
- 3 minutes
- Defaults
- MACD 12, 26, 9Trend 200At-the-money strikeSquare-off 15:15
- Exits
- Opposite signal or square-off; optional stop, target and trailing stop
Supertrend flip
supertrend-buyerBuys a call when the Supertrend turns up and a put when it turns down.
- Candle
- 5 minutes
- Defaults
- ATR period 10Multiplier 3At-the-money strikeSquare-off 15:15
- Exits
- Opposite signal or square-off; optional stop, target and trailing stop
RSI reversal
rsi-buyerBuys a call when RSI climbs back above the oversold level and a put when it falls back below the overbought level.
- Candle
- 5 minutes
- Defaults
- RSI 14Oversold 30Overbought 70Square-off 15:15
- Exits
- Opposite signal or square-off; optional stop, target and trailing stop
Opening range breakout
orb-buyerMarks the high and low of the first minutes of the session, then buys a call on a close above the range or a put on a close below it.
- Candle
- 5 minutes
- Defaults
- Range 15 minutesOne breakout a dayAt-the-money strikeSquare-off 15:15
- Exits
- Opposite breakout or square-off; optional stop, target and trailing stop
Options on your own rules
rule-buyerBuys calls when your bullish conditions all hold and puts when your bearish conditions all hold, from indicators you define.
- Candle
- 5 minutes
- Defaults
- Starts from EMA 9 crossing EMA 21At-the-money strikeEntries 09:15 to 15:00Square-off 15:15
- Exits
- Opposite signal or square-off; optional stop, target and trailing stop
MCX gold futures, long and short
Gold futures on your own rules
futures-traderGoes long a gold or gold mini future when your bullish conditions hold and short when your bearish ones do, reversing in one order when the signal flips.
- Candle
- 5 minutes
- Defaults
- GOLDM by defaultEntries 09:00 to 23:00Square-off 23:15Margin 10% of a lot’s value
- Exits
- Opposite signal or square-off; optional stop, target and trailing stop
Entry rules from 24 indicator series and the close
- Price
- Close
- Moving averages
- SMAEMAWMAHMA
- Trend
- SupertrendADX+DI−DI
- Bands and channels
- Bollinger upperBollinger lowerKeltner upperKeltner lowerDonchian upperDonchian lower
- Oscillators
- RSIStochastic %KStochastic %DWilliams %RCCIRate of change
- Volatility
- ATR
- MACD
- MACDMACD signalMACD histogram
Each indicator takes a period and, where it has one, a multiplier (Supertrend and the bands) or a slow period and signal smoothing (MACD). Empty settings take the indicator’s usual default.
A bullish side, as the builder stores it
Bullish- fast = EMA 9crosses aboveslow = EMA 21
- andtrend = ADX 14above20
- andCloseabovebase = SMA 200
All three must hold on one closed candle. The order fills at the next candle’s open.
| Comparison | Holds when the left side |
|---|---|
crosses_above | Was at or below on the previous closed candle and is above on this one. |
crosses_below | Was at or above on the previous closed candle and is below on this one. |
above | Is above on this closed candle, whatever it did before. |
below | Is below on this closed candle. |
Index-option signals can ignore candles that close after a cutoff time. The shipped moving average buyer uses 15:15, so the closing auction’s jump to the official close never triggers a trade.
A whole strategy, written down as data
A strategy spec says what to trade, when to enter and exit, the risk limits and the costs, as structured JSON. Veloce checks every field before a run starts, so a spec that asks for something impossible is refused with the reason, not run with a guess.
| Field | What it decides | Choices |
|---|---|---|
entry | When to open | A signal (one of six named signals, or your own rules), a first and last entry time, weekdays, a signal cutoff, the fewest days to expiry, and re-entry: when flat, once a day or once per expiry |
legs | What to open on entry or a bullish signal | Options by strike (steps from the money, or the premium closest to a price) and by expiry (the nth, or the nearest at least some days away), or the underlying future; each with a side and a ratio |
bearish_legs | What to open on a bearish signal | The same choices as legs; needs a signal |
square_off | When to close each day | A time, or empty to hold overnight |
exits | When to close | Stop loss, take profit, trailing stop and exit before expiry, checked per leg or per underlying and expiry |
risk | Limits on new lots | Lots per contract, a share of equity, gross exposure, cash, futures margin, loss at expiry and a daily loss limit |
day | Account-wide daily rules | Exit by a time, a daily target and stop, and days to skip |
costs | Fees and slippage | The NSE options or MCX futures schedule, or your own fees and taxes; slippage in ticks or as a share of price |
{
"name": "iron-condor",
"description": "sell weekly iron condors",
"candle_minutes": 1,
"entry": {
"first_entry": "10:00",
"min_days_to_expiry": 5,
"reenter": "each_expiry"
},
"legs": [
{
"kind": "option",
"option_type": "put",
"side": "buy",
"strike": {
"kind": "atm_offset",
"steps": 8
}
},
{
"kind": "option",
"option_type": "call",
"side": "buy",
"strike": {
"kind": "atm_offset",
"steps": 8
}
},
{
"kind": "option",
"option_type": "put",
"side": "sell",
"strike": {
"kind": "atm_offset",
"steps": 4
}
},
{
"kind": "option",
"option_type": "call",
"side": "sell",
"strike": {
"kind": "atm_offset",
"steps": 4
}
}
],
"exits": {
"group_by": "expiry",
"rules": [
{
"kind": "take_profit",
"amount": {
"kind": "share_of_credit",
"fraction": "0.5"
}
},
{
"kind": "stop_loss",
"amount": {
"kind": "share_of_credit",
"fraction": "2"
}
},
{
"kind": "before_expiry",
"days": 1
}
]
}
}{
"name": "futures-trader",
"description": "trade MCX gold futures long and short on your own rules",
"entry": {
"signal": {
"kind": "rules",
"indicators": [
{
"name": "fast",
"kind": "ema",
"period": 9
},
{
"name": "slow",
"kind": "ema",
"period": 21
}
],
"bullish": [
{
"left": "fast",
"comparison": "crosses_above",
"right": "slow"
}
],
"bearish": [
{
"left": "fast",
"comparison": "crosses_below",
"right": "slow"
}
]
},
"first_entry": "09:00",
"last_entry": "23:00"
},
"legs": [
{
"kind": "underlying",
"side": "buy"
}
],
"bearish_legs": [
{
"kind": "underlying",
"side": "sell"
}
],
"square_off": "23:15",
"risk": {
"rules": [
{
"kind": "futures_margin"
}
]
},
"costs": {
"charges": [
{
"kind": "mcx_futures"
}
]
}
}What the checks catch
- A strategy with no legs at all, or bearish legs without a signal to open them.
- A first entry after the last entry, or a last entry at or after the square-off.
- A signal cutoff without a signal, and repeated or missing weekdays.
- Numbers out of range, such as a strike more than 50 steps from the money.
Fields left out take their defaults: a 5-minute candle, one lot a leg, the nearest expiry, the at-the-money strike, the NSE options schedule and one tick of slippage at the next open.
Strategy questions
Do I need to write code to backtest a strategy in Veloce?
No. You can run one of the eleven shipped strategies with your own settings, build entry conditions from indicators, or describe a whole strategy as a spec, which is structured data rather than code.
Which indicators can the rule builder use?
The close and 24 indicator series: SMA, EMA, WMA and HMA; Supertrend, ADX and the two directional indicators; Bollinger, Keltner and Donchian upper and lower bands; RSI, stochastic %K and %D, Williams %R, CCI and rate of change; ATR; and MACD with its signal line and histogram.
When does a rule-based strategy enter?
When every condition on one side holds on the same closed candle, inside the entry window. The order then fills at the open of the next candle, so a signal never trades on the price that produced it.
Can a strategy trade both calls and puts?
Yes. A strategy has legs for a bullish signal and bearish legs for a bearish one. The option buyers buy a call on a bullish signal and a put on a bearish one, and the gold futures strategy goes long or short.
Will the same strategy run in live trading?
That is the design: strategies only return the positions they want, so the same code can run against a live broker with the data and order executor swapped. Paper and live trading are coming soon.
Backtest a strategy on your own settings
Create an account with a verified email and phone number, pick a strategy and a market, and see every fill, fee and day of P&L.