# Running Backtests

## Executing Your First Backtest

Now that you've set up everything properly, it's time to run your backtest and see how BananaEA would have performed historically. This guide walks you through the execution process step-by-step.

{% hint style="success" %}
**Goal**: Execute a complete backtest and generate reliable performance data for analysis.
{% endhint %}

***

## Quick Start: Running a Basic Backtest

### 5-Step Process

1. **Open Strategy Tester** → Press `Ctrl+R`
2. **Configure Settings** → EA, symbol, period, model, spread, dates
3. **Set Parameters** → Load preset or use defaults
4. **Click Start** → Begin backtest execution
5. **Review Results** → Analyze performance metrics

***

## Detailed Backtest Execution

### Step 1: Final Configuration Check

Before clicking \[Start], verify these settings one last time:

**Strategy Tester Settings Tab**:

```
Expert Advisor: BananaEA.ex4 ✅
Symbol: GER40.r ✅
Period: H1 ✅
Model: Every Tick ✅
Spread: 20 points ✅
From: 2023.01.01 ✅
To: 2025.10.20 ✅
Visual mode: Unchecked (for speed) ✅
Optimization: Unchecked (unless optimizing) ✅
```

**Inputs Tab**:

* Parameters loaded correctly ✅
* Preset applied (if using) ✅
* Magic number unique ✅

***

### Step 2: Start the Backtest

**Click \[Start] Button**

What happens next:

```
1. MT4 loads historical data for symbol/timeframe
   ↓
2. EA initializes (OnInit() executes)
   ↓
3. MT4 simulates each bar sequentially
   ↓
4. EA analyzes market conditions per bar (OnTick())
   ↓
5. Trades executed when signals detected
   ↓
6. Results compiled and statistics generated
   ↓
7. "Tester: stop testing" message appears
```

***

### Step 3: Monitor Progress

**Progress Bar** (Bottom of Strategy Tester):

```
Testing: 2024.03.15 14:00  [████████████░░░] 78%
```

**Information Displayed**:

* **Current Date**: Date/time being tested
* **Progress Percentage**: How much completed
* **Bars Processed**: Number of bars analyzed
* **Ticks Simulated**: Tick count (if "Every Tick" mode)

**Estimated Time**:

* **Quick Test** (6 months, Open Prices): 30 seconds - 2 minutes
* **Standard Test** (2 years, Every Tick): 5 - 15 minutes
* **Comprehensive Test** (5 years, Every Tick): 20 - 45 minutes

{% hint style="info" %}
**Duration varies by**: Computer speed, data quality, EA complexity, timeframe, and modeling quality.
{% endhint %}

***

### Step 4: During Backtest Execution

**What You Can Do**:

✅ **Monitor Journal Tab** - Check for errors or warnings ✅ **Watch Progress** - Observe completion percentage ✅ **Minimize MT4** - Let it run in background ✅ **Work on Other Tasks** - No need to watch continuously

**What You Should NOT Do**:

❌ **Don't Close MT4** - Backtest will abort ❌ **Don't Change Settings** - Wait for completion ❌ **Don't Open Heavy Programs** - May slow testing ❌ **Don't Disconnect Internet** - If using live data feed

***

### Step 5: Backtest Completion

**Completion Message**:

```
Tester: stop testing BananaEA-v3.13.21-meanReversion.ex4 (GER40.r,H1)
```

**Results Available**:

* **Results Tab**: Trade-by-trade list
* **Graph Tab**: Equity curve visualization
* **Report Tab**: Comprehensive statistics

***

## Visual Mode Backtesting

### When to Use Visual Mode

**Recommended For**:

* ✅ Verifying signal detection accuracy
* ✅ Debugging entry/exit logic
* ✅ Checking SL/TP placement
* ✅ Understanding EA behavior
* ✅ Confirming indicator display
* ✅ Educational purposes (learning how EA trades)

**NOT Recommended For**:

* ❌ Full 2-year backtests (too slow)
* ❌ Optimization runs (disabled automatically)
* ❌ Final performance validation

***

### Enabling Visual Mode

**Step-by-Step**:

1. Strategy Tester → Settings tab
2. Check "Visual mode" checkbox
3. Configure other settings normally
4. Click \[Start]

**What Appears**:

```
┌─────────────────────────────────────────────┐
│ Chart Window (Visual Backtest)              │
├─────────────────────────────────────────────┤
│ Price Chart with:                           │
│ - Price bars progressing in real-time      │
│ - EA indicators overlaying                 │
│ - Trade arrows when signals fire          │
│ - SL/TP lines on open positions           │
│                                            │
│ [<< Prev] [Pause] [Play] [Next >>]        │
│ Speed: [______|_________] (slider)         │
└─────────────────────────────────────────────┘
```

***

### Visual Mode Controls

**Playback Controls**:

**\[Play] Button**: Resume/continue backtest at current speed\
\&#xNAN;**\[Pause] Button**: Stop execution temporarily\
\&#xNAN;**\[<< Prev]**: Step backward one bar (review previous)\
\&#xNAN;**\[Next >>]**: Step forward one bar (advance manually)

**Speed Slider**:

```
Slowest [|_____________________] Fastest
         ← Detailed observation  Fast screening →
```

* **Slowest**: See every tick, perfect for debugging
* **Medium**: Balanced view, catch signals and trades
* **Fastest**: Quick visual confirmation, less detail

***

### What to Look For in Visual Mode

**Signal Verification**:

* Does EA detect signals when YOU see pattern?
* Are trade arrows appearing at correct times?
* Is entry logic working as expected?

**Entry/Exit Accuracy**:

* Buy/Sell orders placed at correct prices?
* Stop Loss levels appropriate?
* Take Profit targets reasonable?

**Indicator Behavior**:

* Indicators plotting correctly?
* Signal arrows appearing on chart?
* Multi-timeframe data syncing?

**Trade Management**:

* Break-even adjustments triggering correctly?
* Partial closes executing as expected?
* Trailing stop following price appropriately?

{% hint style="warning" %}
**Performance Note**: Visual mode is 10-50x slower than normal backtesting. Use for verification only, not full tests.
{% endhint %}

***

## Handling Backtest Interruptions

### Stopping a Backtest Mid-Execution

**How to Stop**: Click \[Stop] button in Strategy Tester

**What Happens**:

* Backtest aborts immediately
* Partial results may be available
* No report generated (incomplete data)
* Must restart from beginning

**When to Stop**:

* 🛑 Errors flooding Journal tab
* 🛑 Realized wrong settings configured
* 🛑 Need to change parameters
* 🛑 Testing taking unexpectedly long

***

### Common Errors During Execution

#### Error: "No History Data"

**Cause**: Insufficient historical data for test period

**Solution**:

1. Tools → History Center (F2)
2. Download data for symbol/timeframe
3. Restart backtest

***

#### Error: "Testing Failed"

**Cause**: EA compilation error or resource missing

**Solution**:

1. Check Experts tab for error details
2. Open MetaEditor → Compile EA (F7)
3. Fix compilation errors
4. Verify all includes (.mqh files) exist
5. Restart backtest

***

#### Error: "Array Out of Range"

**Cause**: EA trying to access unavailable bars

**Solution**:

1. Check EA code for array access
2. Verify sufficient bars available (e.g., `Bars > 50`)
3. Add data validation in EA code
4. Use longer test period with more data

***

#### Warning: "Not Enough Money"

**Cause**: Initial deposit too small for EA's lot calculation

**Solution**:

1. Increase initial deposit in Strategy Tester
2. Reduce risk percentage in EA parameters
3. Use smaller FixedLotSize if applicable
4. Check LotMethod setting

***

#### Warning: "Invalid Stops"

**Cause**: Stop Loss/Take Profit too close to entry price

**Solution**:

1. Check symbol's minimum stop level (MODE\_STOPLEVEL)
2. Increase SL/TP distances in EA parameters
3. Verify broker's stop level requirements
4. Use larger pip buffers

***

## Post-Backtest Actions

### Immediately After Completion

**Step 1: Quick Visual Check**

```
Click [Open Chart] button
→ Look at equity curve shape
→ Check if results make sense
→ Verify trades appear on chart
```

**Step 2: Review Key Metrics**

```
Results tab → Report
→ Total Net Profit: Positive or negative?
→ Max Drawdown: Acceptable level?
→ Profit Factor: Above 1.5?
→ Total Trades: Sufficient sample size?
```

**Step 3: Save Results**

```
Right-click in Report tab
→ Save as Detailed Report (includes graphs)
→ Choose location and filename
→ Example: "BananaEA_DAX_H1_2023-2025_EveryTick.html"
```

***

### Organizing Backtest Results

**Recommended File Naming Convention**:

```
[EA-Name]_[Symbol]_[Timeframe]_[DateRange]_[Model]_[Version].html

Examples:
BananaEA_DAX_H1_2023-2025_EveryTick_v3.13.21.html
BananaEA_NAS_M5_2024Q1_OpenPrices_v3.13.21.html
BananaEA_DAX_H1_Conservative_2023-2025_v3.13.21.html
```

**Folder Structure**:

```
Backtests/
├── 2023/
│   ├── January/
│   ├── February/
│   └── ...
├── 2024/
│   └── ...
├── 2025/
│   ├── October/
│   │   ├── BananaEA_DAX_H1_2023-2025_EveryTick_v3.13.21.html
│   │   ├── BananaEA_DAX_H1_Aggressive_2023-2025_v3.13.21.html
│   │   └── ...
```

***

## Comparing Multiple Backtests

### Testing Different Parameters

**Scenario**: Compare Conservative vs. Aggressive presets

**Process**:

1. **Test 1**: Load Conservative preset → Run backtest → Save report
2. **Test 2**: Load Aggressive preset → Run backtest → Save report
3. **Compare**: Open both HTML reports side-by-side

**Key Comparisons**:

* **Profit**: Which made more?
* **Drawdown**: Which risked less?
* **Win Rate**: Which had higher success rate?
* **Profit Factor**: Which was more efficient?
* **Recovery**: Which recovered from losses faster?

***

### Testing Different Timeframes

**Scenario**: Compare H1 vs. M15 performance

**Process**:

1. **Test 1**: Period=H1 → Run backtest → Save report
2. **Test 2**: Period=M15 → Run backtest → Save report
3. **Compare**: Analyze trade frequency and risk

**Expected Differences**:

* **M15**: More trades, faster signals, higher frequency
* **H1**: Fewer trades, more selective, larger moves

***

### Testing Different Symbols

**Scenario**: Test DAX vs. NASDAQ vs. DOW

**Process**:

1. **Test 1**: Symbol=GER40.r → Run backtest
2. **Test 2**: Symbol=NAS100.r → Run backtest
3. **Test 3**: Symbol=US30.r → Run backtest
4. **Compare**: Which symbol suits EA best?

{% hint style="info" %}
**Note**: Different symbols have different volatility, spreads, and trading hours. Results will vary significantly.
{% endhint %}

***

## Backtest Validation Checklist

After completing any backtest, verify:

### Data Quality

* [ ] Historical data complete (no gaps)
* [ ] Test period covers 2+ years
* [ ] Includes different market conditions (trends, ranges, volatility)

### Configuration Accuracy

* [ ] Realistic spread used (matches broker)
* [ ] Commission included (if applicable)
* [ ] Swap costs considered
* [ ] Initial deposit matches real capital
* [ ] Modeling quality appropriate ("Every Tick" for validation)

### Results Sanity Check

* [ ] Total trades sufficient (50+ minimum for statistics)
* [ ] Win rate realistic (30-70%, not extremes)
* [ ] Drawdown acceptable (typically 10-30% max)
* [ ] Profit factor reasonable (>1.3 minimum, >1.5 good)
* [ ] No "too good to be true" metrics (100% win rate, zero drawdown)

### Documentation

* [ ] Results saved with descriptive filename
* [ ] Parameters documented (preset used or manual settings)
* [ ] Test date recorded (when backtest run)
* [ ] Notes added (observations, anomalies, insights)

***

## Common Backtesting Scenarios

### Scenario 1: Quick Parameter Screening

**Goal**: Quickly test if parameter change improves results

**Setup**:

* Period: 6 months (recent data)
* Model: Open Prices Only (speed)
* Visual mode: OFF

**Process**:

1. Run baseline test with defaults
2. Change one parameter
3. Run test again
4. Compare results
5. If promising, validate with "Every Tick" on longer period

**Time**: 2-5 minutes per test

***

### Scenario 2: Comprehensive Validation

**Goal**: Thoroughly validate EA before live trading

**Setup**:

* Period: 3-5 years (extensive history)
* Model: Every Tick (accuracy)
* Visual mode: OFF (too slow for long period)

**Process**:

1. Run full backtest on primary symbol (e.g., DAX)
2. Save detailed report
3. Analyze all metrics carefully
4. Validate with forward testing
5. Only then proceed to live testing

**Time**: 20-45 minutes

***

### Scenario 3: Visual Verification

**Goal**: Verify EA logic and signal detection

**Setup**:

* Period: 1-3 months (short, manageable)
* Model: Every Tick
* Visual mode: ON

**Process**:

1. Watch first few days carefully
2. Verify signals trigger correctly
3. Check SL/TP placement
4. Observe trade management
5. Confirm expectations match behavior

**Time**: 30-60 minutes (with pauses for observation)

***

## Tips for Efficient Backtesting

### Time-Saving Strategies

**Use Progressive Testing**:

```
1. Quick screening (6 months, Open Prices) → 2 minutes
   ↓ (If promising)
2. Standard test (2 years, Every Tick) → 10 minutes
   ↓ (If good results)
3. Comprehensive validation (5 years, Every Tick) → 30 minutes
```

**Batch Testing**:

* Run multiple backtests overnight
* Queue tests with different parameters
* Review all results in morning

**Template Settings**:

* Save Strategy Tester configurations
* Load templates for consistent testing
* Avoid reconfiguring each time

***

### Common Time Wasters to Avoid

❌ **Visual Mode on Long Tests** - Use only for short verification\
❌ **"Every Tick" on Initial Screening** - Use faster models first\
❌ **Testing Same Thing Repeatedly** - Document what you tested\
❌ **Not Saving Results** - Always save before running next test\
❌ **Watching Progress Bar** - Let it run, do other work

***

## Next Steps

Now that you know how to run backtests:

1. **Analyze Your Results** → [Analyzing Results](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/analyzing-results)
2. **Learn Optimization** → [Optimization Fundamentals](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/optimization-fundamentals)
3. **Run Optimizations** → [Running Optimizations](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/running-optimizations)
4. **Validate Results** → [Validation & Forward Testing](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/validation-forward-testing)

{% hint style="success" %}
**Pro Tip**: Keep a testing journal. Document every backtest with date, parameters, results, and observations. This becomes invaluable for tracking what works and what doesn't!
{% endhint %}

***

## Related Resources

* [MT4 Strategy Tester Guide](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/strategy-tester-guide) - Interface details
* [Backtesting Setup](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/backtesting-setup) - Configuration guide
* [Best Practices & Tips](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/best-practices) - Professional workflow
* [Introduction to Backtesting](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/introduction) - Fundamentals
