Insights/Insights & Articles/Backtesting in MetaTrader 4: The Complete Strategy Tester Guide

Backtesting in MetaTrader 4: The Complete Strategy Tester Guide

We've run thousands of backtests over twelve years. Thousands. And the one thing we can tell you with absolute certainty is that MT4's Strategy Tester is both indispensable and dangerously misleading. It'll make garbage EAs look like money printers. It'll make solid strategies look broken. The tool is only as good as the person running it.

Mar 25, 2026

Backtesting in MetaTrader 4: The Complete Strategy Tester Guide

Backtesting in MetaTrader 4: The Complete Strategy Tester Guide

We've run thousands of backtests over twelve years. Thousands. And the one thing we can tell you with absolute certainty is that MT4's Strategy Tester is both indispensable and dangerously misleading. It'll make garbage EAs look like money printers. It'll make solid strategies look broken. The tool is only as good as the person running it.

So here's what we actually do when we backtest — the real workflow, the gotchas, the stuff that separates a meaningful backtest from expensive fiction.

Setting Up the Strategy Tester

Step 1: Open the Tester

Ctrl+R or View → Strategy Tester. That's it. Panel pops up at the bottom. If you didn't know this shortcut, we need to talk.

Step 2: Configure the Test

SettingRecommended ValueWhy
Expert AdvisorYour EA's .ex4 file
SymbolThe pair your EA is designed forDon't test EURUSD EAs on GBPJPY
PeriodMatch your EA's intended timeframeH1 EA on H1 chart, M5 on M5
ModelEvery tickMost accurate but slowest
SpreadCurrent (or fixed realistic value)See spread section below
Date range2+ years minimumShort ranges produce meaningless stats
Initial depositMatch your real account size$10K EA on $10K test

Step 3: Model Selection

This is where most people get lazy. The model setting controls how MT4 fabricates price movement between candles — and your choice here basically determines whether your backtest means anything or not:

Every Tick       → Simulates every price change within a bar
                   Most accurate, slowest (10-100x slower)
                   USE THIS for scalping EAs, tight-stop strategies

Control Points   → Generates intermediate prices using lower timeframes
                   Good balance of speed and accuracy
                   USE THIS for H1+ strategies with 20+ pip stops

Open Prices Only → Only tests at bar open
                   Fastest, only valid for EAs that explicitly check
                   if(Time[0] == lastBarTime) before acting
                   USE THIS only if your EA contains a new-bar filter

Here's the thing. Our EAs use a new-bar filter, which is a design choice we're very intentional about:

static datetime lastTickTime = 0;
if (Time[0] == lastTickTime) return;
lastTickTime = Time[0];

That filter makes the EA technically "Open Prices Only" compatible — great for speed. But we don't trust it for final validation. The spread and slippage modeling in that mode is garbage compared to Every Tick. So our workflow? Rapid iteration on Open Prices Only, then a final "is this real?" run on Every Tick. Non-negotiable.

Understanding the Backtest Report

Test finishes, you click the "Report" tab. Now — and we cannot stress this enough — most traders look at the wrong numbers. They see a big green profit figure and start mentally shopping for a Lambo. Stop it. Here's what actually matters:

Metrics That Matter

MetricGood ValueRed Flag
Profit Factor> 1.5< 1.2 (barely profitable)
Expected Payoff> spread cost × 2Negative or near zero
Maximal Drawdown< 20% of initial deposit> 30% (too risky)
Total Trades> 200< 50 (statistically insignificant)
Win RateDepends on R:R> 70% with 1:1 RR is suspicious
Modeling Quality90%+< 25% = garbage data

Metrics That Don't Matter

  • Total Net Profit — We've seen traders brag about $50K profit from a backtest. Then we ask about drawdown. "$45K." Cool, so you almost blew up for a 10% return. Useless number without context.
  • Largest Winning Trade — One outlier trade can carry the entire P&L. Remove it mentally and ask: is this strategy still profitable? Usually the answer is uncomfortable.
  • Consecutive Wins — Flip a coin enough times and you'll get 8 heads in a row. Doesn't make you psychic. Streaks are noise.

Reading the Equity Curve

Forget every number on the report for a second. Look at the equity curve. We're dead serious — the shape of that curve tells us more in two seconds than ten minutes of staring at stats:

GOOD: Smooth, upward-sloping curve with small, brief drawdowns
      → Strategy has consistent edge across market conditions

BAD:  Flat for months, then a spike, then flat again
      → Strategy only works in one market condition

WORST: Stairstep with deep drops
       → Strategy is a martingale or grid — profitable until it isn't

Spread: The Silent Killer

Why Default Spread Settings Lie

This one makes us genuinely angry. MT4's Strategy Tester uses the current spread by default. Think about that. Run your backtest on a Sunday night when your broker's spread is 50 pips on EUR/USD? Congratulations, every single simulated trade just used that spread. Run it during London session? Now you've got fairy-tale tight spreads across years of data. Neither is remotely realistic. We've seen traders build entire strategies on top of this lie without realizing it.

Setting a Realistic Spread

Here's what we use — these are 5-digit broker values that reflect real-world conditions, not the fantasy numbers you see in marketing material:

EUR/USD  →  10-15 points (1.0-1.5 pips on 5-digit broker)
GBP/USD  →  15-20 points
USD/JPY  →  10-15 points
GBP/JPY  →  30-40 points
XAU/USD  →  25-35 points
NAS100   →  100-150 points

We bake a spread filter directly into every EA we build. Period. Here's the technique we covered in the Risk Management article:

input double MaxSpreadPoints = 20.0;

// In OnTick, before any entry:
double currentSpread = (Ask - Bid) / Point;
if (currentSpread > MaxSpreadPoints) return;  // Skip this tick

In live trading, that filter saves you from getting wrecked during news spikes and illiquid hours. For backtesting, do the opposite of what feels natural — set the tester spread to your worst realistic scenario, not your best. If your EA still profits under ugly conditions, you've got something real.

Optimization

What Optimization Does

Optimization is simultaneously the most powerful and most dangerous feature in the entire Strategy Tester. MT4's optimizer brute-forces your EA through thousands of parameter combos and ranks results by whatever metric you choose. When used correctly, it reveals your strategy's sweet spots. When used carelessly — which is most of the time — it produces curve-fitted garbage that blows up on the first live trade.

Setting Up an Optimization

  1. Click Expert Properties in the Strategy Tester
  2. Go to the Inputs tab
  3. For each parameter to optimize, check the box and set Start, Step, Stop:
Parameter         Start    Step    Stop     Combinations
ATRMultiplierSL   1.0      0.5     3.0      5
TP_Multiplier     1.0      0.5     3.0      5
ATRPeriod         7        7       28       4
RiskPercent       0.5      0.5     2.0      4

Total: 5 × 5 × 4 × 4 = 400 parameter combinations
  1. Check Optimization checkbox
  2. Click Start — MT4 tests all 400 combinations

Reading Optimization Results

Once it finishes, click the Optimization Results tab. And for the love of everything, sort by Profit Factor — not profit. Sorting by profit is how you find overfitted junk:

PassProfitProfit FactorDrawdownTrades
237$12,4002.31$3,200487 ← BEST
104$18,9001.87$8,100612 ← Risky
391$8,2002.54$1,900298 ← Stable
15$31,0001.24$22,0001,203 ← Overfitted

We'd pick Pass 237 without hesitation. Solid profit factor, manageable drawdown, enough trades to be statistically meaningful. Pass 15? Highest raw profit, sure. Lowest profit factor. That thing was swinging for the fences and getting lucky. Put it on a live account and watch it hemorrhage money.

Optimization Traps

Overfitting is enemy number one. If your top parameter set shows a profit factor above 3.0 and the runner-up plummets to 1.5 or below, you haven't found a strategy. You've found a coincidence. A statistical mirage. We see this constantly — traders fall in love with that one magic parameter set and refuse to accept it's noise.

Run a sensitivity check. What we want to see is a "plateau" — a cluster of nearby parameter values that all perform well. If bumping ATRMultiplierSL from 1.5 to 2.0 nukes your profit by 80%, that's not a strategy. That's a house of cards. Real edges are robust. They survive a little parameter drift.

Our non-negotiable: the 70/30 split. Optimize on 70% of your data. Then take those winning parameters and run them on the remaining 30% — data the optimizer has never seen. If it loses money? You didn't find a strategy. You found patterns in noise. Walk away. This single step has saved us from more bad EAs than we can count.

Common Backtesting Mistakes

Mistake 1: Survivorship Bias on Symbols

Everyone defaults to EUR/USD because "it's the most liquid." Great. But your strategy is a trend-follower, and EUR/USD has been chopping sideways for months. You just proved your EA can lose money on a range-bound pair. Shocking. Test on the instruments you're actually going to trade. Sounds obvious, but we'd say half the backtests we review make this exact mistake.

Mistake 2: Ignoring Commission and Swap

// Your backtest shows $5,000 profit
// But you forgot to set commission in the tester:
// Commission = $7 per lot round-turn
// 500 trades × $7 = $3,500 in commissions
// Actual profit = $1,500

We've reviewed backtests from clients showing beautiful profits — then they go live and bleed. Why? They never set commissions. Expert Properties → Testing tab. Punch in your broker's actual rates. It takes five seconds and can turn a "winner" into an obvious loser before you risk real money.

Mistake 3: Stop Loss at Exact Levels

Here's a fun one. The Strategy Tester fills your stop loss at the exact price you set. Perfect execution, every time. Know what happens in live trading? Slippage. Your SL at 1.1200 fills at 1.1195. Or 1.1190 during NFP. A strategy with a slim $500 edge gets that edge eaten alive by slippage that the backtest never simulated.

Our fix: always add a slippage buffer:

input int Slippage = 3;  // 3 point slippage allowance

// In OrderSend:
OrderSend(Symbol(), OP_BUY, lots, Ask, Slippage, sl, tp, ...);

Mistake 4: Zero Orders = "No Bugs"

"My EA ran for 5 years and took zero trades. Is it just being patient?" No. It's broken. Zero trades means something is fundamentally wrong, and we debug this for clients more often than we'd like to admit. The usual suspects:

  • Wrong timeframe — EA built for H1, you tested on M1. Classic.
  • Symbol name mismatch — EA has "EURUSD" hardcoded, but your broker calls it "EURUSDm" or "EURUSD.raw". Infuriating.
  • Trading hours filter excludes the entire test period. Oops.
  • Lot size calculation returns 0 because the account balance is too small for your risk parameters. Math doesn't lie.

Mistake 5: Testing Only Bull Markets

2020-2021 only? That post-COVID rocket ship? Of course your buy strategy crushed it. A monkey throwing darts at a buy button would've crushed it. That backtest proves nothing about your strategy's edge. You need to punish your EA with bad markets, not just flatter it with good ones:

2018-2019  →  Range-bound, choppy
2020       →  COVID crash + recovery
2021       →  Strong trend
2022       →  Rate hike reversal
2023-2024  →  Mixed

Three years minimum. Bull, bear, and chop. If your EA can't handle all three, it doesn't have an edge — it has a bias.

Code: Making Your EA Backtest-Friendly

Print Diagnostic Information

void OnTick()
{
    // Useful in testing — shows why trades aren't opening
    if (!IsTradingHour())
    {
        if (MathMod(Minute(), 15) == 0)  // Every 15 min
            Print("Outside trading hours: ", TimeToString(TimeCurrent()));
        return;
    }

    if (SpreadInPoints() > MaxSpreadPoints)
    {
        Print("Spread too wide: ", SpreadInPoints(), " > ", MaxSpreadPoints);
        return;
    }

    // ... entry logic
}

Visual Mode for Debugging

Tick Visual mode in the Strategy Tester and actually watch your EA trade on the chart. We know, it's slow. We know, you want to skip ahead. Don't. This is hands-down the fastest way to catch logic bugs that numbers alone will never reveal:

  • Are entries firing where you expect, or is the EA buying into resistance like a rookie?
  • Do the SL/TP levels make sense visually, or is your stop sitting inside the spread?
  • Is the EA even opening trades when it should?

Testing Multiple Symbols

Basket strategies — EAs that trade multiple pairs — are a headache to backtest properly in MT4. The tester is fundamentally single-symbol. So you have to test on each symbol individually AND verify cross-symbol behavior on the primary chart.

// In OnInit, verify all symbols are available in the tester:
void ValidateSymbols()
{
    string symbols[] = {"EURUSD","GBPUSD","USDJPY","AUDUSD"};
    for (int i = 0; i < ArraySize(symbols); i++)
    {
        double price = MarketInfo(symbols[i], MODE_BID);
        if (price == 0)
            Print("WARNING: ", symbols[i], " not available in tester!");
    }
}

Look, we've been doing this for over a decade. Backtesting right takes experience, paranoia, and an almost pathological distrust of your own results. If you don't want to spend weeks figuring out which settings are lying to you, we handle this at Quantumcona — rigorous backtesting with realistic spreads, commissions, slippage, and 5+ years of properly modeled data. No shortcuts.

Submit Your EA for Backtesting →

Article 11 of 20 in the Algo Trading Masterclass by Quantumcona. Next up: walk-forward testing — because if you thought backtesting was hard, wait.

1of8