Skip to content

Learn Backtesting

Everything you need to get started with professional strategy testing.

Quick Start - Get your first backtest running in under 60 seconds

The fastest way to get started is with guest mode - no signup required!

What You Get:

  • ✅ 3 free backtests
  • ✅ Popular symbols (SPY, AAPL, GOOGL, MSFT)
  • ✅ 30 days of historical data
  • ✅ Core technical indicators
  • ✅ Full results and metrics

Your First Strategy

Once you're in the app, you'll see a pre-loaded demo strategy. Here's what it does:

python
BACKTEST_CONFIG = {
    'start_date': '20240101',
    'end_date': '20240201',
    'initial_capital': 10000
}

def on_bar_close(data_contexts, portfolio, state):
    """Simple moving average crossover"""
    data = data_contexts['SPY']
    
    # Calculate moving averages
    sma_fast = data.sma(10)  # 10-day average
    sma_slow = data.sma(20)  # 20-day average
    
    # Skip if not enough data
    if sma_fast is None or sma_slow is None:
        return
    
    # Buy when fast crosses above slow
    if sma_fast > sma_slow and portfolio.position('SPY') == 0:
        shares = int(portfolio.cash * 0.5 / data.close)
        if shares > 0:
            buy('SPY', shares)
    
    # Sell when fast crosses below slow
    elif sma_fast < sma_slow and portfolio.position('SPY') > 0:
        sell('SPY', portfolio.position('SPY'))

Steps:

  1. Review the Strategy - The code is already loaded
  2. Click "Run Backtest" - See results in seconds
  3. Modify and Experiment - Try changing parameters
  4. Sign Up When Ready - Get unlimited backtests

Option 2: Create a Free Account

Want to save strategies and get more features? Create a free account:

  1. Visit app.backtestingengine.com
  2. Click "Sign Up" - Use email or Google
  3. Verify Email - Check your inbox
  4. Start Testing - 480 compute minutes free/month

Free Account Benefits:

  • 💾 Save unlimited strategies
  • 📊 Access all symbols
  • 📈 Full historical data
  • 🔧 Advanced indicators
  • 📤 Export results

Understanding the Interface

Editor Panel (Left)

  • Strategy Code: Write your Python strategy here
  • Syntax Highlighting: Automatic Python highlighting
  • Auto-Save: Changes saved as you type (logged-in users)
  • Examples Menu: Load pre-built strategies

Results Panel (Right)

  • Metrics Tab: Key performance indicators
  • Trades Tab: Individual trade details
  • Chart Tab: Equity curve visualization
  • Logs Tab: Debug output from your strategy

Key Concepts

1. Strategy Structure

Every strategy needs:

  • BACKTEST_CONFIG: Define dates and capital
  • on_bar_close(): Main logic executed each bar

2. Data Access

python
data = data_contexts['SPY']  # Get symbol data
price = data.close           # Current close price
sma = data.sma(20)           # 20-day moving average

3. Order Execution

python
buy('SPY', 100)              # Buy 100 shares
sell('SPY', 50)              # Sell 50 shares
sell_all('SPY')              # Close entire position

4. Portfolio Info

python
cash = portfolio.cash                    # Available cash
position = portfolio.position('SPY')     # Current shares
equity = portfolio.equity                # Total value

Common Patterns

Pattern 1: Momentum Strategy

python
if data.close > data.sma(50):
    # Uptrend - go long
    if portfolio.position('SPY') == 0:
        buy('SPY', 100)
elif portfolio.position('SPY') > 0:
    # Exit position
    sell_all('SPY')

Pattern 2: Mean Reversion

python
rsi = data.rsi(14)
if rsi < 30 and portfolio.position('SPY') == 0:
    # Oversold - buy
    buy('SPY', 100)
elif rsi > 70 and portfolio.position('SPY') > 0:
    # Overbought - sell
    sell_all('SPY')

Pattern 3: Risk Management

python
# Position sizing based on portfolio
position_size = int(portfolio.equity * 0.02 / data.close)

# Stop loss
if portfolio.position('SPY') > 0:
    entry_price = state.get('entry_price', data.close)
    if data.close < entry_price * 0.95:  # 5% stop loss
        sell_all('SPY')

What Just Happened?

When you run a backtest:

  1. Historical Data Loaded - Real market data from the date range
  2. Strategy Executed - Your code runs on each trading day
  3. Orders Simulated - Buys and sells executed at market prices
  4. Performance Calculated - Metrics computed from results

Common Questions

Q: Is this using real money? A: No! This is a simulation using historical data. No real money involved.

Q: Why start with guest mode? A: You can test immediately without signup. Perfect for learning.

Q: What symbols can I trade? A: Guest mode: SPY, AAPL, GOOGL, MSFT. Free account: All US stocks.

Q: How accurate is the simulation? A: We use real historical data with realistic execution modeling.

Next Steps

Learning Paths

📚 Complete Beginner

  1. What is Backtesting? - Core concepts
  2. First Strategy Tutorial - Build from scratch
  3. Example Library - Study working strategies

🔧 Ready to Code

  1. API Reference - All available functions
  2. Strategy Development - Advanced patterns
  3. Best Practices - Professional techniques

💡 Strategy Ideas

  1. Basic Strategies - Start with simple concepts
  2. Advanced Examples - Complex implementations
  3. Risk Management - Protect your capital

Tips for Success

  • Start Simple - Master basic strategies before complex ones
  • Test Thoroughly - Try different time periods and market conditions
  • Manage Risk - Always include stop losses and position sizing
  • Keep Learning - Markets evolve, so should your strategies

Ready to Test Your Ideas?

No signup required. Start backtesting in seconds.

Launch Guest Mode →

Test your trading strategies risk-free with professional backtesting.