Skip to main content

Search Modes — Sequential vs Smart

TL;DR

Sequential Mode tests every combination in the parameter grid — guaranteed to find the global best on the test window, but combinatorial: 4 inputs at 20 steps each = 160,000 runs. Smart Mode optimizes one input at a time, locks the best value, then moves to the next input, repeating for N rounds — dramatically fewer runs, no global-best guarantee, but practical on large grids. Pick by grid size: ≤ a few thousand → Sequential, otherwise → Smart.

Sequential Mode

Sequential Mode is the exhaustive grid search. It iterates through every combination of the input ranges you defined.

The number of runs is the product of the steps per field:

total runs = steps_field_1 × steps_field_2 × ... × steps_field_N
SetupSteps per fieldTotal runs
2 inputs, 10 steps each10 × 10100
3 inputs, 20 steps each20 × 20 × 208,000
4 inputs, 20 steps each20⁴160,000
5 inputs, 10 steps each10⁵100,000

At roughly 1-3 seconds per backtest, 8,000 runs is around 2-6 hours. 160,000 runs is days. Plan your ranges accordingly.

AspectSequential
ProsGuaranteed to find global best on the test window. Deterministic results — same setup, same numbers.
ConsCombinatorial explosion. Quickly impractical above a few thousand combinations.
When to useSmall parameter spaces (≤ ~5,000 combinations) or when you need absolute certainty for a final tune.

Smart Mode

Smart Mode is a heuristic — it doesn't test every combination. Instead it optimizes inputs one by one, locking in the best value before moving on, and repeats for the number of search rounds you define. Here is a worked example with three inputs:

3 input fields, each with its own range:
Field 1: [1 … 100]
Field 2: [1 … 50]
Field 3: [1 … 150]

Start with every field at its minimum:
Field 1 = 1, Field 2 = 1, Field 3 = 1

Round 1
Sweep Field 1 over [1–100], hold Field 2 = 1, Field 3 = 1 → best Field 1 = 45
Sweep Field 2 over [1–50], hold Field 1 = 45, Field 3 = 1 → best Field 2 = 20
Sweep Field 3 over [1–150], hold Field 1 = 45, Field 2 = 20 → best Field 3 = 31
End of round 1: (45, 20, 31)

Round 2 (starts from the round-1 result)
Sweep Field 1 over [1–100], hold Field 2 = 20, Field 3 = 31 → best Field 1 = 80
Sweep Field 2 over [1–50], hold Field 1 = 80, Field 3 = 31 → best Field 2 = 47
… and on through Field 3

Repeat for N rounds, or stop early when a round produces no improvement.

The number of runs:

total runs = (steps_field_1 + steps_field_2 + ... + steps_field_N) × rounds
SetupPer-round runs3 roundsSequential equivalent
3 inputs, 20 steps each601808,000
4 inputs, 20 steps each80240160,000
5 inputs, 10 steps each50150100,000

Two orders of magnitude fewer runs. Smart Mode also short-circuits if a round produces no improvement — so the practical runtime is often less than the worst case.

AspectSmart
ProsMassively faster on large grids. Scales to many inputs without the combinatorial explosion. Early-stops when improvement stalls.
ConsNo global-best guarantee. Can get stuck in a local optimum if Field 1's best in isolation isn't the best in combination with other fields.
When to useLarge parameter spaces (>5,000 combinations), broad exploration phases, or when you want a fast first pass.

Search criterion (what to optimize for)

Pick one criterion for the run — Strategy Finder sorts and "best result" decisions are based on this metric.

CriterionOptimizes forWatch out for
Net profitHighest total currency P&LOverfits on trending markets. Long-only on a bull window always looks great.
Percent profitableHighest win rateA high win rate with small wins and big losses can still lose money overall.
Profit factorHighest gross-profits-to-gross-losses ratioLess prone to overfit than net profit, but still gameable by cherry-picking trade size.

For most strategies, profit factor + drawdown filter is the most robust pairing.

Drawdown filter

The drawdown filter excludes any combination whose max drawdown exceeds your threshold from the ranking (and optionally from the run itself).

This is the single most important guardrail against backtest overfitting. Without it, the "best" parameters will always be the most aggressive ones — and they'll blow up live.

ThresholdTypical use
≤ 5%Conservative, low-leverage strategies
≤ 10-15%Mainstream — most published systems target this range
≤ 20-25%Aggressive momentum / trend-following
> 25%You're optimizing for noise

Wait function

Strategy Finder injects a configurable delay between each backtest run. The delay exists because TradingView's UI can freeze or rate-limit if the Strategy Tester is driven too fast.

DelayEffect
0-500 msFast, but flaky on complex strategies — TV may skip a tester refresh
1-3 secondsRecommended default — stable across most strategies
3+ secondsUse for very complex Pine scripts that take a while to recompute

Save / Load search configurations

A saved config bundles:

  • The list of inputs you're varying
  • Each input's min, max, step
  • Search criterion and drawdown filter
  • Search mode (Sequential / Smart) and round count
  • Wait delay

Use cases:

  • Same strategy, multiple pairs — load the config once per symbol.
  • Same strategy, multiple timeframes — sweep on 1h, then load again on 4h.
  • Walk-forward analysis — re-run the same config across rolling windows.

CSV Export

Every result row exports to CSV with the input columns plus the metric columns (net profit, percent profitable, profit factor, max drawdown, trade count). Open in Excel, Google Sheets, or pandas for:

  • Pivot tables across input dimensions
  • Custom scoring formulas (e.g. profit factor × win rate / drawdown)
  • Plots of metric surface vs input value
  • Aggregating runs across multiple timeframes or pairs

Best practices

  1. Start small. Sweep 2-3 inputs with coarse steps first to learn the strategy's sensitivity surface. Don't burn hours on a 5-input sweep before you know which inputs even matter.
  2. Always run a drawdown filter. Optimizing on net profit alone is the fastest path to a strategy that overfits on backtest and loses live.
  3. Validate out-of-sample. Run the sweep on the first 70-80% of your history. Take the best parameters and test them on the held-out 20-30%. If the metrics collapse, you overfit.
  4. Walk-forward. Roll the optimization window forward in 3-6 month chunks. If the "best" parameters change wildly each chunk, the strategy is unstable.
  5. Combine criteria. Use the drawdown filter first to cull risky combinations, then sort survivors by profit factor.
  6. Beware of trade-count cliffs. A combination with 8 trades and 100% win rate is statistically meaningless. Filter by minimum trade count in the CSV.
  7. Use Smart Mode for exploration, Sequential for the final tune. Sweep broadly with Smart, then take the top region of the parameter space and sweep it densely with Sequential.

When NOT to backtest

SituationWhy it breaks backtesting
Strategy uses request.security() with lookaheadTradingView's lookahead semantics produce future-information leakage on historical bars
Fewer than ~50 trades in the test windowSample size too small to be statistically meaningful
Illiquid asset (new altcoin, low-volume pair)Backtest assumes infinite liquidity at the bar's price — reality is brutal slippage
Strategy depends on order-book microstructureTradingView only has OHLCV — microstructure-dependent strategies cannot be validated this way
Different exchange than the chart symbolSpreads, fees, and tick sizes differ — backtest on the exchange you'll trade on

From backtest to live trading

StepAction
1Lock in the parameters you found with Strategy Finder (write them into the Pine input.* defaults).
2Add a strategy.entry / strategy.close call with an alert_message argument carrying your JSON payload — see Strategy Alerts.
3Build the JSON payload with the Trade Command Builder.
4Create a TradingView alert on the strategy with Webhook URL = your TVH webhook endpoint and Message = {{strategy.order.alert_message}}.
5Test in paper-trading mode first if your exchange supports it.
6Monitor live performance — compare actual fills, slippage, and metrics against the backtest.

A backtest is a hypothesis. Live trading is the experiment. Strategy Finder makes the hypothesis cheaper to generate — it doesn't validate that the hypothesis is real.