Skip to Content
Core WorkflowsExecution & Backtesting

Execution & Backtesting

Learn how to run your strategy against historical data and configure execution parameters for optimal testing.

What is Backtesting?

Backtesting means running your trading strategy against historical market data to see how it would have performed in the past. It’s like a time machine that shows you what trades your strategy would have made and how much profit or loss it would have generated.

Important: Past performance doesn’t guarantee future results, but backtesting helps you understand if your strategy logic is sound.

Starting an Execution

Once you have generated code, you’ll see an Execute button appear below the chat. Click it to open the execution configuration dialog.

The Execution Dialog

A dialog box opens with several configuration options organized in tabs:

  1. Strategy Name (top of dialog)
  2. Data Source tab
  3. Parameters tab

Let’s go through each section:

Naming Your Strategy

At the top of the execution dialog, you’ll see a text field with an auto-generated name like:

Auto-saved strategy 3:45:12 PM

You should change this to something meaningful:

Good Names:

  • “MA Crossover 10-30 SPY”
  • “RSI Mean Reversion 14”
  • “MACD Trend Following”
  • “Bollinger Band Breakout v1”

Why naming matters:

  • Easy to find strategies later
  • Compare different versions
  • Understand what each strategy does at a glance

Tip: Include key parameters in the name (e.g., “MA 20-50” tells you the periods used).

Selecting Data Sources

Click the Data Source tab to choose what historical data to test against.

Available Data

You’ll see a list of available data sources. Each entry shows:

  • Symbol Name: The market instrument (e.g., “SPY”, “BTCUSDT”, “EURUSD”)
  • Description: What the symbol represents (when available)
  • Type: OHLCV or Custom data

How to Select Data

Single Data Source:

  1. Click the checkbox next to the symbol name
  2. Only selected symbols will be highlighted

Multiple Data Sources:

  1. Check multiple symbols
  2. Your strategy will be tested on each one
  3. Results will show performance across all selected data

Multi-Instrument Note: If you select multiple data sources, your strategy will have access to all of them during execution. This is useful for portfolio strategies or comparing performance across markets.

Choosing the Right Data

For Testing Your Logic:

  • Start with one data source
  • Choose a symbol you’re familiar with
  • Use clean, complete data

For Validation:

  • Test on multiple data sources
  • Try different market conditions
  • Compare results across markets

Example Data Selection

Scenario: Testing a Moving Average Strategy

  • ✅ Select “SPY” (S&P 500 ETF - liquid, trending market)
  • ✅ Good for trend-following strategies
  • ✅ Long history available

Scenario: Crypto Trading Strategy

  • ✅ Select “BTCUSDT” (Bitcoin/USDT)
  • ✅ High volatility for testing edge cases
  • ✅ 24/7 market data

No Data Available? See Data Management to learn how to upload your own data.

Configuring Parameters

Click the Parameters tab to configure your strategy’s adjustable values.

Understanding Parameters

Remember those parameters defined at the top of your strategy code? This is where you set their values for this specific backtest.

Example Parameters:

INITIAL_CAPITAL: 100000.0 FAST_SMA_PERIOD: 10 SLOW_SMA_PERIOD: 30 RSI_PERIOD: 14

Parameter Configuration

For each parameter, you’ll see:

  • Parameter Name: The variable name (e.g., “FAST_SMA_PERIOD”)
  • Current Value: The value (with increment/decrement buttons)
  • Description: What this parameter controls (from code comments)

Adjusting Parameters

To Change a Value:

  1. Click the button to decrease
  2. Click the + button to increase
  3. Or type a new value directly in the field

Example Adjustments:

Original:

FAST_SMA_PERIOD: 10 SLOW_SMA_PERIOD: 30

Testing a Slower Strategy:

FAST_SMA_PERIOD: 20 SLOW_SMA_PERIOD: 50

Initial Capital Parameter

Every strategy has this critical parameter:

INITIAL_CAPITAL: 100000.0

This sets how much money your strategy starts with. Common values:

  • 10,000: Small account testing
  • 100,000: Standard backtesting amount
  • 1,000,000: Institutional-size testing

Why it matters: Position sizes and overall returns depend on your starting capital. Use an amount similar to what you’d actually trade with.

Parameter Optimization Tips

Start with Defaults: The generated code has sensible defaults - try those first

Change One at a Time: Test the effect of individual parameter changes

Logical Ranges: Keep values realistic:

  • Moving Average periods: 5-200
  • RSI periods: 2-30
  • Capital: $1,000 - $10,000,000

Document Tests: Note which parameter values you’ve tried

Advanced Users: You’ll eventually want to test multiple parameter combinations. For now, focus on one set of values per backtest.

Common Parameters Explained

Parameter TypeExampleWhat It Controls
Indicator PeriodsSMA_PERIOD: 20How many bars to calculate over
ThresholdsRSI_OVERSOLD: 30Trigger levels for signals
CapitalINITIAL_CAPITAL: 100000Starting portfolio size
RiskSTOP_LOSS_PCT: 0.02Risk management levels

Date Range Configuration

Note: Currently, date ranges are automatically configured by the platform based on available data. Future versions will allow custom date range selection.

The backtest will run over the complete historical data available for your selected symbols.

Running the Backtest

Once you’ve configured everything:

  1. Review Your Settings:

    • Strategy name is meaningful
    • Data source(s) selected
    • Parameters are set appropriately
  2. Click the Run Button at the bottom of the dialog

  3. Execution Begins:

    • Dialog closes
    • Strategy is saved (if new) or updated (if existing)
    • Backtest starts processing

Monitoring Execution Progress

After clicking Run, watch the Canvas panel for execution status:

Status Messages

You’ll see different status indicators:

“Processing…”

  • Backtest is running
  • Strategy is being executed against historical data
  • This can take a few seconds to a few minutes

“Executing”

  • Initial stage of execution
  • Strategy code is being loaded
  • Data is being prepared

“Completed”

  • ✅ Backtest finished successfully
  • Results are ready to view
  • Reports have been generated

“Failed”

  • ❌ Something went wrong
  • Error message will be displayed
  • See Troubleshooting below

Execution Time

Typical Duration:

  • Small datasets (< 1 year daily data): 5-15 seconds
  • Medium datasets (1-5 years daily data): 15-45 seconds
  • Large datasets (5+ years or intraday): 45-180 seconds

Factors Affecting Speed:

  • Amount of historical data
  • Strategy complexity
  • Number of indicators
  • Trade frequency
  • Number of data sources

Be Patient: Complex strategies on large datasets can take a couple of minutes. Don’t refresh the page!

Understanding Execution Stages

During execution, your strategy goes through several stages:

1. Validation

  • Code is checked for errors
  • Framework compatibility verified
  • Parameters validated

2. Data Loading

  • Historical market data retrieved
  • Data formatted correctly
  • Timeframe aligned

3. Execution

  • Strategy runs through historical data
  • Indicators calculated on each bar
  • Trades generated based on signals
  • Positions managed

4. Results Generation

  • Performance metrics calculated
  • Visualizations created
  • Report compiled

5. Display

  • Results shown in Canvas
  • Charts rendered
  • Metrics displayed

After Execution Completes

When execution finishes successfully:

  1. Canvas Updates: Automatically switches to show results
  2. Report Displayed: Execution summary, metrics, and charts appear
  3. Chat Confirmation: Lona confirms success with a summary message

You can now analyze your results! Continue to Results & Analysis.

Re-Running with Different Parameters

Want to test how parameter changes affect performance?

Option 1: From the Chat

  1. Stay in the same chat
  2. Click Execute again
  3. Adjust parameters
  4. Click Run

Result: Creates a new execution report, previous results are still accessible in Reports section.

Option 2: From Strategies Page

  1. Navigate to Strategies in left sidebar
  2. Find your strategy
  3. Click the pencil icon to edit/execute
  4. Configure and run

Troubleshooting Execution Issues

”Execution Failed” Error

Common Causes:

1. Data Issues

  • Problem: No data selected or data unavailable
  • Solution: Select at least one data source, verify data exists

2. Invalid Parameters

  • Problem: Parameter values are invalid (e.g., negative period)
  • Solution: Check parameters are positive numbers in reasonable ranges

3. Code Errors

  • Problem: Edited code has syntax errors
  • Solution: Regenerate code from requirements or fix syntax errors

4. Timeout

  • Problem: Execution took too long (>5 minutes)
  • Solution: Try with smaller date range or less data

”Strategy Not Saved” Error

Cause: Issue saving strategy to database Solution: Try executing again; if persists, regenerate code

Execution Hangs (No Updates)

Cause: Network issue or processing problem Solution:

  1. Wait 2-3 minutes
  2. Refresh the page
  3. Navigate to Reports to check if execution completed

No Results Showing

Cause: Results generated but Canvas is hidden Solution:

  • Click Canvas Size button in left sidebar
  • Set to “Half” or “Full” to see results
  • Ensure Canvas Mode is set to “Report”

Best Practices for Execution

Testing Strategy

Start Simple:

  • One data source
  • Default parameters
  • Complete date range

Validate Logic First:

  • Does the strategy trade as expected?
  • Are entry/exit signals correct?
  • Do indicators make sense?

Then Optimize:

  • Try different parameters
  • Test on multiple markets
  • Compare results

Parameter Testing

Systematic Approach:

  • Change one parameter at a time
  • Document each test
  • Note which combinations work best

Reasonable Ranges:

  • Moving averages: 5-200 periods
  • RSI/Stochastic: 5-30 periods
  • Initial capital: $10K-$1M

Data Selection

Match Your Goals:

  • Stock strategy → Test on stock ETFs (SPY, QQQ)
  • Crypto strategy → Test on major cryptos (BTCUSDT, ETHUSDT)
  • Forex strategy → Test on major pairs (EURUSD, GBPUSD)

Diverse Conditions:

  • Test in trending markets
  • Test in ranging markets
  • Test in volatile periods

Advanced Execution Topics

Multi-Symbol Testing

When you select multiple data sources:

  • Strategy has access to all symbols simultaneously
  • Useful for portfolio strategies
  • Can compare correlations
  • Tests diversification effects

Strategy Versioning

Each time you execute, you can:

  • Keep the same strategy name (updates strategy)
  • Use a new name (creates new version)

Versioning Strategy:

"MA Crossover v1" → Initial version "MA Crossover v2" → After optimizing periods "MA Crossover v3" → After adding filters

Execution Checklist

Before clicking Run, verify:

  • Strategy has a meaningful name
  • At least one data source is selected
  • Parameters are in reasonable ranges
  • Initial capital is appropriate
  • You’re ready to wait for results (don’t close browser)

What’s Next?

Once your backtest completes, you’ll want to understand the results! Continue to Results & Analysis to learn how to interpret performance metrics and charts.

Quick Reference

ActionLocation
Start ExecutionExecute button below chat
Name StrategyTop of execution dialog
Select DataData Source tab
Adjust ParametersParameters tab
Run BacktestRun button in dialog
View StatusCanvas panel (Report mode)
Access ResultsCanvas panel after completion
Re-runExecute button again

Next: Learn how to interpret your backtest results in Results & Analysis.

Last updated on