Backtest Parameter Sweep
tt_backtest_sweepSweep ONE strategy parameter across a grid on Tradetron's own backtest fleet — a run per value; returns a job id, and the report link comes from the status poll. Use to answer "which entry time / strike offset / SL is best?" without hand-editing and re-submitting N backtests.
SINGLE-AXIS ONLY: one search variable, N values. It is NOT a multi-parameter grid — to explore a second parameter, run a second sweep.
BILLING (when enabled server-side): a sweep is charged PER VARIANT — every value
in values is one engine run debited at the per-run backtest fee from the user's
Tradetron WALLET, so N values cost N x the per-run fee (e.g. 5 values = 5 x the
fee). The same consent gate as tt_backtest_strategy applies: a chargeable sweep
first returns {code: BT_CONFIRM_CHARGE, price, wallet_balance} with the TOTAL
price for all variants and submits NOTHING — relay the exact amount and the
variant count to the user, and only after they agree re-call with the SAME
arguments plus confirm_charge=true. A rejected or failed sweep is auto-refunded.
A successful submit carries {billing: {charged, variants, rate, wallet_balance}} —
mention the total charge in one short sentence, never as a surprise.
Args:
confirm_charge: set True ONLY after the user has been told the exact total fee
(per-variant fee x number of values) and agreed to it. Never set it on your
own initiative.
template: the strategy object (with a 'sets' array), passed INLINE. Unlike
tt_backtest_strategy, this tool has NO strategy_id parameter: for a strategy
already saved in the user's account, call tt_get_strategy(strategy_id) first
and pass its data.strategy here as template. Fetching also carries the
template's id, and that id is what the fleet sweeps. A hand-built inline
template has no id, so it is REFUSED uncharged ("isn't saved in your Tradetron
account") — save it with tt_create_strategy, re-fetch it with tt_get_strategy,
and sweep THAT object. The refusal says "backtest by strategy_id" because it is
shared with the backtest tools that take one; here it means that round-trip.
start, end: 'YYYY-MM-DD' window; on NSE/NFO/BFO end must be at least
35 days before today, elsewhere yesterday (BT_WINDOW_TOO_RECENT otherwise, refused before any charge). type / trade_price / capital / candle_freq /
slippage_bps / tt_match: identical meaning to tt_backtest_strategy.
search: a parameter of THIS strategy to vary — e.g. an entry time "0930", a
strike offset, an SL number. Tradetron validates it server-side against the
strategy's own parameters, and does so on the routing check, so a name the
strategy does not carry is refused FREE and BEFORE the price question, quoting
Tradetron's own sentence ("'X' is not a parameter of this strategy. Pick one
from the list."). That arrives as {ok: False, error} — take the list it names
and re-call. It is NOT a fuzzy substring match over the template JSON.
values: the grid to try — 2 to 10 strings (hard limits; validated here before
submit). One sequential engine run per value.
oos_pct: per-variant WALK-FORWARD fold, default 30 (the service clamps 10–50), so
each variant is judged in-sample vs out-of-sample — pick by IS, judge by OOS.
name: optional label for the run; defaults to the template name.
stop_check: 'close' (default) | 'high_low', the same as tt_backtest_strategy. Every
variant is run with it. A high_low sweep runs only on Tradetron's fleet; it is never
sent to the fallback engine.
TIMING: variants run SEQUENTIALLY, ~300s each, so a 10-value intraday sweep can take many minutes. This is submit-and-watch — open watch_url for progress; it is never synchronous. A sweep counts as ONE inflight job; our single source IP allows max 4 concurrent backtests total (shared across all MCP backtest tools).
RESULTS: poll with tt_backtest_status. The per-variant ranking currently renders in the HTML report (report_url in the status). A machine-readable per-variant summary is being added service-side; once live, tt_backtest_status will also carry structured per-variant results in its summary — this tool passes through whatever summary/results the status returns and does not require them to be present yet.
Returns {ok, job_id, watch_url, status_url, state, note} (+ fidelity_caveat as tt_backtest_strategy). On a bad search / validation reject: {ok: False, error, findings}.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"template": "<template>",
"start": "<start>",
"end": "<end>",
"search": "<search>",
"values": "<values>"
},
"name": "tt_backtest_sweep"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | Yes | ||
| name | No | ||
| type | No | 'intraday' force-closes all positions at 15:30 daily, 'positional' carries overnight. Wrong type = wrong numbers. | positional |
| start | Yes | ||
| search | Yes | ||
| values | Yes | ||
| capital | No | ||
| oos_pct | No | ||
| template | Yes | ||
| tt_match | No | Reproduce TT-BT lot conventions — set True only for parity runs against a Tradetron backtest. Default False. | |
| stop_check | No | How Entry, Exit, Universal Exit and Repair conditions that compare a price with a fixed level (stop losses, targets, breakout entries) are checked on each candle. 'close' (default, the website's default too) checks the candle's close only, so a level the price wicked through inside the minute but closed back from does not fire. 'high_low' checks the candle's high and low: a stop or an entry on that instrument fills at its level (or at the open on a gap through it), and when one candle reaches both the stop and the target the stop is taken. A Stoploss keyword inside a repair still reads the close. Use 'high_low' when the user asks for stops, targets or breakout entries to respect intrabar highs and lows. | close |
| candle_freq | No | Candle cadence in MINUTES (e.g. 1, 5, 60). Default 1. | |
| trade_price | No | Fill-price field per candle. Default 'Open', matching the website's Backtest dialog and tt_backtest_strategy — a 'Close' fill hands every price-triggered condition a minute of look-ahead, and it would make this sweep's baseline incomparable with a single run. | Open |
| slippage_bps | No | Slippage in basis points applied per fill. Default 0 (no slippage modelled). | |
| confirm_charge | No |