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:
| Worker | Role | Purpose |
|---|---|---|
| Trigger | Start | Launches the workflow manually or on a schedule |
| Fetch Prices | Data | Downloads OHLC price data for XAUUSD and EURUSD |
| Swing Finder | Analysis | Detects swing highs and lows in price action |
| Backtest Strategy | Evaluation | Tests the swing signals with configurable risk parameters |
| Parameter Loop | Optimization | Sweeps 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:
| Field | Value | Description |
|---|---|---|
| Data source | {{workers[1].result}} | Connect to Fetch Prices output |
| Swing sensitivity | 3 | How many bars to look back for swing detection |
| Min swing size | 0.001 | Minimum 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:
| Field | Value | Description |
|---|---|---|
| Signals | From Swing Finder | Swing signals with entry direction |
| Initial capital | 10000 | Starting capital in USD |
| Commission | 0.001 | 0.1% per trade |
| Slippage | 0.0005 | 0.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:
| Field | Value | Why |
|---|---|---|
| Collect field | result.sharpe_ratio | Extract Sharpe ratio from backtest output |
| Ranking field | sharpe_ratio | Rank by this value |
| Ranking mode | max | Higher Sharpe ratio = better |
Safety settings:
| Field | Value | Purpose |
|---|---|---|
| Max iterations | 0 (unlimited) | Let all 25 iterations run |
| Continue on error | true | Skip 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:
| Iteration | p.stop_loss | p.take_profit | r.sharpe_ratio | r.total_return | r.max_drawdown | ms |
|---|---|---|---|---|---|---|
| 1 | 1.0 | 2.0 | 0.42 | 8.3% | -12.1% | 137 |
| 2 | 1.0 | 3.0 | 0.58 | 11.2% | -10.5% | 131 |
| 3 | 1.0 | 4.0 | 0.61 | 12.8% | -9.8% | 133 |
| ... | ... | ... | ... | ... | ... | ... |
| 7 | 2.5 | 4.0 | 1.87 | 24.3% | -6.2% | 129 |
| 8 | 2.5 | 5.0 | 1.65 | 21.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:
- Click the winning row in the results table
- The frontend sets the corresponding parameters on the Backtest Strategy worker
- 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
- Best iteration — automatically highlighted, shows the optimal parameter combination
- Consistency — check if nearby parameter values also perform well (a stable optimum is better than a sharp peak)
- Trade count — ensure the best combination actually triggered enough trades to be statistically meaningful
- Drawdown — don't only optimize for returns; check that the best combo keeps max drawdown manageable
Example: Comparing Two Winners
| Metric | SL=2.5, TP=4.0 (ranked #1) | SL=3.0, TP=5.0 (ranked #2) |
|---|---|---|
| Sharpe ratio | 1.87 | 1.72 |
| Total return | +24.3% | +26.1% |
| Max drawdown | -6.2% | -12.8% |
| Win rate | 62% | 58% |
| Trades | 47 | 43 |
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 Loop | With Parameter Loop |
|---|---|
| Manually change parameters | Define range once |
| Run strategy, note result | Click Run Test |
| Change parameters again | All 25+ combos run automatically |
| Compare manually | Results ranked and highlighted |
| Guess the best combo | Best 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.
Legal Disclaimer
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.