Two Expert Advisors (EAs) can finish a backtest with the same net result and the same maximum drawdown and still be very different things to trade. Picture one that climbs in small, regular steps, and another that goes nowhere for a year and a half, then makes most of its gains in two months. The summary report treats them as near-identical, because it describes the end point and one bad moment, not the path between them.
The path matters for two practical reasons. It tells you how long you would have waited between new equity highs, which is what decides whether you keep running an EA through a flat period. And it tells you whether the result is spread across the test or concentrated in a few stretches of history. This guide covers the metrics that describe the path, how to calculate them from your own equity data, and how to put a range around each one so you don't read too much into a single curve.
One point up front: every metric here describes the historical equity curve you feed it. A smooth backtest curve is not evidence that the live curve will be smooth, and some of the smoothest backtests are the most overfit.
Why one drawdown number isn't enough
Maximum drawdown is the largest peak-to-trough fall in the test. It is useful, but it leaves out most of the curve:
- Duration. A drawdown recovered in three weeks and one of the same depth that lasts fourteen months produce the same maximum drawdown.
- Frequency. One deep drawdown and five moderate ones can share the same maximum.
- Concentration. A curve whose gains come from a few short bursts has the same end point as one whose gains are spread evenly, but the first depends far more on those particular bursts recurring.
Our guide to drawdown metrics explains the definitions behind maximum, relative, balance and equity drawdown. The metrics below build on those definitions to describe the whole path.
Step 1: Build the right equity series
Every stability metric is only as good as the series it is calculated on. Three choices matter:
- Equity, not just closed trades. A curve built from closed trades hides the losses an open position carried before it closed. Where you can, use end-of-day equity with open positions valued at that day's close. Our drawdown guide covers why the two differ.
- Fixed position size, or log equity. If the EA compounds, later trades are larger, and a curve that looks steady in currency terms may hide a weakening edge. Calculate the metrics on a fixed-size version of the test, or on the logarithm of equity, so early and late periods are comparable.
- Calendar time, not trade number. Plotting equity against trade number removes the flat stretches when the EA wasn't trading, which are exactly the periods duration metrics are meant to catch. Use one row per trading day, including days with no trades.
Step 2: Measure linearity with R-squared
Fit a straight line through the equity curve against time. R-squared is the share of the curve's variation that the line explains: close to 1 for a curve that hugs a straight line, lower for one that wanders.
It is popular because it is simple, but read it with care:
- It ignores direction. A curve that falls steadily also has a high R-squared. Always read it next to the slope.
- Cumulative curves flatter it. Any running total tends to drift, even a running total of random numbers, so a fairly high R-squared on an equity curve proves less than the same value would elsewhere. That is one reason Step 6 compares it with reshuffled curves.
- It doesn't care about scale. A curve that rises a tiny amount very steadily can score higher than one that rises a lot with some bumps.
A related measure divides the fitted slope by its standard error, which rewards a curve that rises both steadily and meaningfully. Versions of this are sometimes called a K-ratio, and published formulas scale it differently, so state the formula you use. The daily changes along an equity curve are not independent of the line through them, so treat this number as a description of the path, not a significance test.
Step 3: Combine depth and duration with the Ulcer index
The Ulcer index, introduced by Peter Martin, measures how far below its previous peak the curve sits, on average, over the whole test. For each day, take the percentage drawdown from the running peak (zero on a day that sets a new high). Square those values, average them, and take the square root.
Because the drawdowns are squared, deep drawdowns weigh more than shallow ones. Because every day counts, a long drawdown adds to the index for as long as it lasts. So it captures depth and duration together, which maximum drawdown cannot. Two practical notes:
- It needs a positive equity series, such as account equity, not a cumulative profit series that starts at zero.
- With fixed position size, the percentage drawdowns depend on the starting balance you assume. Use the same starting balance when you compare versions of a strategy, or calculate drawdowns in currency or in multiples of risk per trade.
Step 4: Measure time under water and stagnation
Duration metrics answer the question traders actually feel: how long would I have waited?
- Longest time under water: the longest stretch, in calendar days, between one equity high and the next.
- Share of time under water: the fraction of days on which equity sat below its previous peak. Many reasonable strategies spend most of their time below a previous high, so this is a number to know in advance, not a fault in itself.
- Current time since the last high: the same measure at the end of the test, which matters once you are monitoring the EA live.
Count trades as well as days. A drawdown that lasted six months but contained only eight trades says less about the strategy than one that contained eighty. Our guide to Monte Carlo testing shows how drawdown depth varies across reshuffled orderings; duration varies just as much.
import numpy as np
import pandas as pd
def stability_metrics(equity: pd.Series) -> dict:
"""equity: end-of-day account equity (positive values), one row per trading day, fixed position size."""
y = equity.dropna().astype(float).to_numpy()
t = np.arange(len(y))
slope, intercept = np.polyfit(t, y, 1)
resid = y - (slope * t + intercept)
r_squared = 1 - (resid ** 2).sum() / ((y - y.mean()) ** 2).sum()
slope_se = np.sqrt((resid ** 2).sum() / (len(y) - 2) / ((t - t.mean()) ** 2).sum())
peak = np.maximum.accumulate(y)
dd_pct = (y - peak) / peak * 100 # 0 on a new high, negative below it
under = y < peak
longest = run = 0
for below in under:
run = run + 1 if below else 0
longest = max(longest, run)
return {"r_squared": r_squared, "slope_per_day": slope, "slope_to_se": slope / slope_se,
"ulcer_index_pct": np.sqrt(np.mean(dd_pct ** 2)),
"share_days_under_water": under.mean(),
"longest_days_under_water": longest, "days_since_last_high": run}
The function counts rows, so "days" here means trading days in your series. If you need calendar days, take the dates at the start and end of the longest run from the index.
Step 5: Check consistency across sub-periods
Split the test into equal sub-periods, such as quarters, and look at each one on its own:
- Share of sub-periods with a positive result, and the worst sub-period.
- How much of the total came from the best few sub-periods. If removing the best two quarters takes the whole test to roughly flat, the result depends on conditions that may not come back.
- Rolling expectancy per trade over a fixed window of trades, plotted across the test. A rolling line that drifts steadily downwards is worth investigating even if the full-period figure looks acceptable.
When sub-period results differ sharply, find out why before deciding what it means. Different market conditions, a change in the broker's data or costs, or a period when the EA hardly traded can all produce the same picture.
Step 6: Put ranges on every metric
A single equity curve is one ordering of the trades the EA happened to take. Reshuffle the daily results many times, rebuild the curve each time and recalculate the metrics, and you get a range for each one.
def metric_ranges(daily_pnl: pd.Series, start_equity: float, n: int = 2000, seed: int = 11) -> pd.DataFrame:
"""Reshuffle daily P&L, rebuild equity, and report the 5th, 50th and 95th percentile of each metric."""
rng = np.random.default_rng(seed)
pnl = daily_pnl.dropna().to_numpy()
rows = [stability_metrics(pd.Series(start_equity + np.cumsum(rng.permutation(pnl)))) for _ in range(n)]
return pd.DataFrame(rows).quantile([0.05, 0.5, 0.95])
Choose a starting equity that matches the account you would actually trade, so that no reshuffled path falls to zero and the percentage figures mean something. Reshuffling single days assumes they are independent. If bad days cluster, reshuffle blocks of consecutive days instead, as our Monte Carlo guide describes.
Reading the observed curve against the reshuffled ones
- Plan with the range, not the backtest's own value. If the 95th percentile of the longest time under water is far longer than the backtest showed, that longer figure is a better basis for deciding how long a flat spell you would accept.
- A curve much smoother than its reshuffles deserves a closer look. It can mean the history contained a run of favourable conditions in a particular order, or that losses were deferred, for example by an EA that holds losing trades open while it closes winners. Check open-trade drawdown and the trade list before treating the smoothness as quality.
- Compare versions with the same method. A change that improves the backtest's R-squared but leaves the reshuffled ranges where they were has mostly changed the ordering of one history.
Step 7: Don't optimize on smoothness
It is tempting to make R-squared or the Ulcer index the optimizer's target. Any single score can be gamed by the search: the optimizer will find parameter sets that produce a smooth curve on this history, including ones that do it by trading rarely or by holding losers. Our guide to custom optimization criteria in MT5 explains how to combine a score with hard rules, such as a minimum trade count, and why the top row of an optimization is not the one to trade.
Used as a check after the search, on parameters you have already frozen and on data the search never saw, stability metrics are far more informative than they are as a target.
Common equity-curve mistakes
- Calculating metrics on closed-trade equity, which hides open-trade drawdown.
- Using compounded equity, so later trades dominate the metrics.
- Plotting against trade number, which deletes the flat periods duration metrics exist to catch.
- Reading R-squared without the slope, or as if a cumulative curve's R-squared were strong evidence.
- Ignoring duration because the maximum drawdown looked acceptable.
- Treating the backtest's single curve as the expected path instead of one draw from a range.
- Optimizing on smoothness, then reporting the smoothness of the optimized result as a finding.
Equity-curve stability checklist
- Metrics calculated on end-of-day equity, with open positions valued, one row per trading day
- Fixed position size or log equity used, so early and late periods are comparable
- R-squared read together with the slope, with the formula for any slope-to-error measure stated
- Ulcer index calculated with a starting balance matching the intended account
- Longest and current time under water recorded in days and in trades
- Sub-period results reviewed, including the share of the total from the best periods
- Every metric given a reshuffled range, with blocks used if bad days cluster
- Metrics used as checks on frozen parameters and unseen data, not as the optimizer's target
Frequently asked questions
What is a good R-squared for an equity curve?
There is no threshold that separates good from bad. A cumulative equity curve tends to drift, so a fairly high R-squared is common even for weak strategies, and a steadily falling curve also scores high. Read it with the slope, compare it with reshuffled versions of the same trades, and compare versions of a strategy using the same calculation.
What is the Ulcer index in trading?
It is the square root of the average squared percentage drawdown from the running peak, taken over every day of the test. Squaring weights deep drawdowns more heavily, and counting every day means long drawdowns add to it for as long as they last, so it reflects both depth and duration.
What is time under water?
Time under water is the time equity spends below its previous high. The longest stretch between one equity high and the next is the figure most traders care about, because it shows how long a strategy went without making new progress in the test. Record it in calendar days and in number of trades.
Is a smoother equity curve always better?
No. Smoothness can come from a genuinely consistent strategy, but it can also come from overfitting, from a favourable ordering of one history, or from an EA that defers losses by holding losing trades open. Check open-trade drawdown, compare the curve with reshuffled versions and test on data the strategy never saw.
Should I use equity-curve metrics as an optimization target?
It is safer to use them as checks. An optimizer will find parameters that make any single score look good on the data it searched, so a smooth optimized curve is partly a product of the search. Freeze the parameters first, then measure stability on out-of-sample data and across reshuffled orderings.
Want a second pair of eyes?
Start with our free Sample Stress-Test Report. It walks one anonymized, illustrative strategy through a full stress test, start to finish, so you can see what rigorous validation looks like before you test your own.
Read the Sample Stress-Test ReportWant your own backtest checked? The Strategy Audit + 60-minute call is a paid service at a launch price of £100, credited in full against our build and portfolio offers. You send an MT4/MT5 Strategy Tester report or trade-list CSV; what we can check depends on the files you supply, and walk-forward and parameter sweeps are not included because they need the strategy itself. It is analysis of strategy testing, not investment advice, and does not promise any trading or evaluation outcome. See the Strategy Audit
Disclaimers
CollosoTrading provides educational content and analytical services for retail and professional algorithmic traders. We do not provide regulated investment advice, financial advice, or personal recommendations. Trading derivatives, leveraged products, and CFDs carries a high level of risk and may result in losses exceeding deposits. Past performance, including any verified or unverified historical results referenced on this site, is not indicative of future results. Consult an independent regulated financial adviser before making investment decisions.
All figures are backtests or simulations unless marked LIVE. Hypothetical or backtested performance results have inherent limitations and may not reflect actual trading. No representation is made that any account will or is likely to achieve profits or losses similar to those shown. Individual results vary. This article contains no performance figures; the code examples produce your own test results. We do not guarantee the outcome of any prop firm challenge.