Skip to main content

Parameter Loop - Find Your Strategy's Sweet Spot in Minutes

Every trading strategy has parameters — stop loss, take profit, indicator periods, position size. The difference between a profitable strategy and a losing one often comes down to getting these numbers right. But manually testing every combination is tedious, and guessing rarely works.

The Parameter Loop worker takes the guesswork out of strategy tuning. Drop it onto your canvas, define the range of values you want to test for each parameter, click Run Test, and watch as the system automatically executes your strategy with every combination — streaming results into a live table before your eyes.

What Problem Does It Solve?

Imagine you have a swing trading strategy that uses a 14-period RSI and a SMA crossover. You suspect it works better with different values, but testing 10 RSI levels × 10 SMA periods × 5 stop loss values = 500 combinations manually is impossible.

Parameter Loop runs all 500 iterations automatically, ranks every result, and shows you the best combination in seconds. No coding required — just drag, drop, and configure.

How It Appears in the Interface

The Parameter Loop has a distinctive two-column dialog layout that sets it apart from other workers:

  • Left column — Configure your sweep: select which worker to test, define parameter ranges, and set ranking options
  • Right column — Live results table that updates as each iteration completes, showing every parameter combination and its outcome

On the canvas, the node displays with a dashed border and two connection handles:

  • Left handle (out) — Connect to the worker whose parameters you want to test
  • Right handle (in) — Optional, connect upstream data sources

Complete Workflow: Gold & EURUSD Swing Strategy Optimization

Let's walk through a real-world example that shows Parameter Loop in action — a multi-symbol swing trading strategy for Gold (XAUUSD) and EURUSD.

Workflow Architecture

[Trigger] → [Fetch Prices] → [Swing Finder] → [Backtest Strategy] → [Parameter Loop]

Here's what each worker does:

WorkerRolePurpose
TriggerStartLaunches the workflow manually or on a schedule
Fetch PricesDataDownloads OHLC price data for XAUUSD and EURUSD
Swing FinderAnalysisDetects swing highs and lows in price action
Backtest StrategyEvaluationTests the swing signals with configurable risk parameters
Parameter LoopOptimizationSweeps across SL/TP combos to find the best-performing set

Step 1: Set Up the Trigger

Add a Trigger worker to your canvas. Choose Manual for testing or set a Schedule (e.g., every 15 minutes) for live optimization.

No special configuration needed — the trigger simply starts the workflow when you click Run.

Step 2: Fetch Price Data

Add a Fetch Prices worker and configure it to pull data for your symbols:

{
"symbols": ["XAUUSD", "EURUSD"],
"timeframe": "5m",
"limit": 5000
}

What the user sees in the UI: A dropdown to select symbols, a timeframe selector (1m, 5m, 15m, 1h, 4h, 1d), and a data limit field.

The output is a DataFrame with OHLCV columns (time, open, high, low, close, volume) for both symbols.

Step 3: Detect Swing Points

Add a Swing Finder worker and connect the Fetch Prices output to its input. Configure it to detect meaningful swing highs and lows:

Configuration fields in the right panel:

FieldValueDescription
Data source{{workers[1].result}}Connect to Fetch Prices output
Swing sensitivity3How many bars to look back for swing detection
Min swing size0.001Minimum price movement to consider a swing

The Swing Finder analyzes price action and outputs detected swing points with entry prices, stop loss levels, and targets.

Step 4: Set Up the Backtest

Add a Backtest Strategy worker and connect the Swing Finder output. This is where you define your base strategy parameters:

Configuration:

FieldValueDescription
SignalsFrom Swing FinderSwing signals with entry direction
Initial capital10000Starting capital in USD
Commission0.0010.1% per trade
Slippage0.00050.05% slippage per trade

The Backtest worker simulates trading the swing signals and produces comprehensive statistics: Sharpe ratio, total return, max drawdown, win rate, and more.

Step 5: Add Parameter Loop for Optimization

Now the key step — add the Parameter Loop worker and connect it after the Backtest Strategy. In the two-column dialog:

Left Column - Sweep Configuration

Connect to worker: Select Backtest Strategy from the dropdown (this is the worker being tested).

Define sweep parameters:

[
{"name": "stop_loss", "values": [1.0, 1.5, 2.0, 2.5, 3.0]},
{"name": "take_profit", "values": [2.0, 3.0, 4.0, 5.0, 6.0]}
]

This creates a 5 × 5 = 25-iteration grid, testing every combination of SL from 1% to 3% and TP from 2% to 6%.

Alternative: Use range notation

Instead of writing a JSON list, you can use natural range notation in the input field:

1.0-3.0:0.5

This generates [1.0, 1.5, 2.0, 2.5, 3.0] automatically — no need to write every value.

Ranking settings:

FieldValueWhy
Collect fieldresult.sharpe_ratioExtract Sharpe ratio from backtest output
Ranking fieldsharpe_ratioRank by this value
Ranking modemaxHigher Sharpe ratio = better

Safety settings:

FieldValuePurpose
Max iterations0 (unlimited)Let all 25 iterations run
Continue on errortrueSkip any failed iterations and keep going

Session label: gold_eurusd_swing_sl_tp_v1

This label saves your results so you can load them later without re-running.

Right Column - Live Results Table

Once you click ▶ Run Test on the Parameter Loop node, the right column comes alive:

Iterationp.stop_lossp.take_profitr.sharpe_ratior.total_returnr.max_drawdownms
11.02.00.428.3%-12.1%137
21.03.00.5811.2%-10.5%131
31.04.00.6112.8%-9.8%133
.....................
72.54.01.8724.3%-6.2%129
82.55.01.6521.1%-7.4%130

The best iteration (highest Sharpe ratio at 1.87) is highlighted in green. Failed iterations appear in red. You can click any row to inspect its detailed output.

The table columns are dynamic — they adapt based on what the backtest returns. You can use the Output Field Picker to select exactly which metrics to display.

Step 6: Apply the Best Parameters

After the sweep completes, the best parameters (stop_loss = 2.5, take_profit = 4.0) are highlighted and ready to use. The workflow is paused on the Parameter Loop node — the best parameters have NOT been automatically saved yet.

To apply them:

  1. Click the winning row in the results table
  2. The frontend sets the corresponding parameters on the Backtest Strategy worker
  3. Save the workflow manually to persist the optimized values

Now your strategy is tuned with proven parameters.

Workflow Variations

Multi-Timeframe Optimization

Test the same strategy across different timeframes:

[Fetch Prices] → [Swing Finder] → [Backtest] → [Parameter Loop]

(sweep: interval)

Sweep parameters:

[
{"name": "interval", "values": ["1m", "5m", "15m", "1h", "4h"]},
{"name": "stop_loss", "values": [1.0, 2.0, 3.0]}
]

Indicator Period Sweep

Find the optimal RSI or SMA periods:

[Fetch Prices] → [Add Indicator] → [Signal Generator] → [Backtest] → [Parameter Loop]

Sweep parameters for RSI period:

[
{"name": "rsi_period", "values": [7, 14, 21, 28]},
{"name": "rsi_overbought", "values": [70, 75, 80]},
{"name": "rsi_oversold", "values": [20, 25, 30]}
]

Position Size Optimization

Test different risk levels:

[Fetch Prices] → [Swing Finder] → [Backtest] → [Parameter Loop]

Sweep parameters:

[
{"name": "position_size", "values": [0.05, 0.1, 0.15, 0.2, 0.25]},
{"name": "stop_loss", "values": [1.0, 2.0, 3.0]}
]

Multi-Asset Parameter Testing

Test across different symbols at once — connect a Data Fetcher that returns multiple symbols:

[Fetch Multi-Symbol] → [Swing Finder] → [Backtest] → [Parameter Loop]

The Parameter Loop treats each backtest run independently, so you can compare performance across assets with the same parameter set.

Production Mode: Using Best Parameters in Live Trading

Once you've found the optimal parameters, you don't want the Parameter Loop to run a full sweep every time your scheduled workflow triggers. The Production Mode setting handles this automatically.

Configuration for Live Use

Set Production Mode to use_best:

prodMode: "use_best"

This tells the Parameter Loop:

  • During scheduled runs → Load the best parameters from your saved session and use them directly (no sweep)
  • During manual Run Test → Run the full sweep as normal

The result is seamless: optimize with sweeps during development, use optimized values in production.

Pinned Parameters (No Session Required)

You can also pin specific values without a saved session:

"pinnedBestParameters": {
"stop_loss": 2.5,
"take_profit": 4.0
}

This is useful when you already know the best values from prior analysis and want to hard-code them for production.

Tips for Effective Parameter Sweeps

Start Coarse, Then Refine

Run a coarse grid first (3 × 3 = 9 iterations) to find the approximate optimum, then refine around the winner with a finer grid:

Round 1 — Coarse:

stop_loss: [1.0, 2.0, 3.0]
take_profit: [2.0, 4.0, 6.0]

9 iterations. Winner: SL=2.0, TP=4.0

Round 2 — Fine around winner:

stop_loss: [1.5, 2.0, 2.5]
take_profit: [3.0, 4.0, 5.0]

9 iterations. Winner: SL=2.5, TP=4.0

Use Max Iterations as a Safety Net

For large sweeps, set maxIterations to a reasonable cap during development:

maxIterations: 50

This prevents accidentally running a 10,000-iteration sweep on a slow worker. Lift the cap for the final run.

Always Name Your Sessions

Setting a sessionLabel saves the full results to the Sessions tab, so you can:

  • Compare results across different sweep configurations
  • Re-apply best parameters later without re-running
  • Share results with team members

Use Continue on Error

Keep continueOnError: true during exploration. Some parameter combinations may fail (e.g., stop loss too tight, no trades triggered), but you don't want one bad combo to abort the entire sweep.

Interpreting Results

What to Look For

  1. Best iteration — automatically highlighted, shows the optimal parameter combination
  2. Consistency — check if nearby parameter values also perform well (a stable optimum is better than a sharp peak)
  3. Trade count — ensure the best combination actually triggered enough trades to be statistically meaningful
  4. Drawdown — don't only optimize for returns; check that the best combo keeps max drawdown manageable

Example: Comparing Two Winners

MetricSL=2.5, TP=4.0 (ranked #1)SL=3.0, TP=5.0 (ranked #2)
Sharpe ratio1.871.72
Total return+24.3%+26.1%
Max drawdown-6.2%-12.8%
Win rate62%58%
Trades4743

Even though #2 has higher total return, #1 has lower drawdown and higher Sharpe — making it the more robust choice for live trading.

Performance

The Parameter Loop is built for speed. A 25-iteration sweep on a 5,000-bar backtest completes in under 5 seconds. For comparison, running the same 25 iterations manually would take 10-15 minutes of clicking.

Key performance features:

  • Concurrent execution — iterations run in parallel (configurable up to 8 concurrent)
  • Executor-based — sweeps run on the dedicated executor process with full numpy/pandas/TA-Lib stack
  • Live streaming — results appear in the table as each iteration completes

Summary

The Parameter Loop worker turns strategy tuning from a manual chore into a one-click operation:

Without Parameter LoopWith Parameter Loop
Manually change parametersDefine range once
Run strategy, note resultClick Run Test
Change parameters againAll 25+ combos run automatically
Compare manuallyResults ranked and highlighted
Guess the best comboBest combo identified instantly

Whether you're tuning a swing trading stop loss, optimizing indicator periods, or finding the right position size — Parameter Loop does the heavy lifting so you can focus on building better strategies.

This documentation is for educational purposes only. Past performance of optimized parameters does not guarantee future results. Trading involves substantial risk of loss. Always test strategies thoroughly before deploying with real capital.