Drawdown and Equity Curve
What is a drawdown and an equity curve?
An equity curve is a line chart of an account's or strategy's value over time. A drawdown is a fall in that value from its highest point so far, the running peak, to a later low, measured in percent or currency. The maximum drawdown is the deepest of these falls: the worst loss suffered from a top.

A simulated strategy and benchmark over five years: the equity curves with the strategy's running peak (top) and the underwater chart of drawdowns (bottom), with the 24.1% maximum drawdown shaded from peak to recovery (sample data). Try the interactive version.
- Drawdown is the value divided by its running peak, minus one. It is zero at a new high and negative below it.
- Maximum drawdown measures depth; drawdown duration measures how long the account stays below its old high.
- Losses and gains are not symmetrical: a 50% loss needs a 100% gain to get back.
- Plot long equity curves on a log scale, so equal percentage moves have equal height.
- The Calmar ratio divides annual return by maximum drawdown.
What is an equity curve?
An equity curve shows how much an account, fund or trading strategy is worth at each point in time, so its shape shows growth and losses together.
- The value can be in currency ($10,000 growing to $18,000), or as cumulative return from a starting value of 100 or 1. Starting every curve at the same value makes curves comparable.
- The horizontal axis is usually calendar time: daily, weekly or monthly values. A backtest report often plots it against trade number instead, one point per closed trade, which hides how long each trade took.
- Live accounts include deposits and withdrawals, which move the curve without any gain or loss. Use returns, or a unitised value like a fund's price per share, so cash moves don't look like performance.
- A benchmark, such as a stock index or a simple buy-and-hold position, is often drawn on the same chart for comparison.
Linear or log scale for an equity curve?
For an equity curve that spans several years or a large change in value, a log scale is usually the better choice. On a linear axis a move from $10,000 to $20,000 takes the same height as a move from $100,000 to $110,000, so early gains and losses look tiny and recent ones look huge. On a log axis, equal heights mean equal percentage changes: doubling from $10,000 to $20,000 is as tall as doubling from $20,000 to $40,000. Compounding growth at a steady rate becomes a straight line, and a drawdown of 20% looks the same size wherever it happens. The log scale graph guide explains how log axes work and when to use them.
What is drawdown?
Drawdown is how far an account is below its highest value so far, measured from that peak.
To find it, keep a running peak, the highest value reached up to each date. Then, on every date:
where is the value on date . The result is 0 on a day the account makes a new high and negative below it, so −0.25 means 25% below the peak. In currency, the drawdown is .
A drawdown has three points and three lengths:
| Term | Meaning |
|---|---|
| Peak | The high the drawdown is measured from |
| Trough | The lowest value before the account gets back to the peak |
| Recovery | The first date the value is back at or above the peak |
| Decline (peak to trough) | How long the fall took |
| Recovery time (trough to recovery) | How long it took to make the loss back |
| Duration (peak to recovery) | The whole time spent below the old high, also called time underwater |
Many reports say "drawdown" when they mean the maximum drawdown. A current drawdown is the one the account is in today; it may get deeper before it ends.
How to calculate maximum drawdown
Maximum drawdown is the most negative drawdown over the whole period:
It is usually quoted as a positive percentage ("a 25% maximum drawdown"), though some software returns it as a negative number. The steps are:
- Walk through the values in date order, updating the running peak.
- On each date, divide the value by the running peak and subtract 1.
- The smallest (most negative) result is the maximum drawdown. Note the peak it was measured from and the date of the trough.
- Search forward from the trough for the first value at or above that peak: that is the recovery date. If there is none, the drawdown hasn't recovered yet.
Worked example: ten months of account values
| Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct |
|---|---|---|---|---|---|---|---|---|---|---|
| Account value ($) | 100,000 | 120,000 | 90,000 | 110,000 | 130,000 | 117,000 | 112,000 | 125,000 | 128,000 | 135,000 |
| Running peak ($) | 100,000 | 120,000 | 120,000 | 120,000 | 130,000 | 130,000 | 130,000 | 130,000 | 130,000 | 135,000 |
| Drawdown ($) | 0 | 0 | −30,000 | −10,000 | 0 | −13,000 | −18,000 | −5,000 | −2,000 | 0 |
| Drawdown (%) | 0 | 0 | −25.0 | −8.3 | 0 | −10.0 | −13.8 | −3.8 | −1.5 | 0 |
- The maximum drawdown is 25%, or $30,000: from the February peak of $120,000 to the March trough of $90,000.
- That drawdown recovered in May, when the account reached $130,000, above its old peak. Its duration was three months: one month falling and two recovering.
- The second drawdown was shallower, 13.8% at its July low, but it lasted five months, from the May peak to the October recovery. It is the longest drawdown in the series, though not the deepest.
- Over the ten months the account gained 35%.
Choose the data frequency with care. The March low of $90,000 is a month-end value; daily data could show a deeper intramonth low. Maximum drawdown measured from monthly data is never deeper than the same series measured daily.
Drawdown duration and recovery time
Drawdown duration is the time from a peak until the account first gets back to it, and it matters as much as depth.
A shallow drawdown can last for years, and a long spell without a new high tests an investor's patience and a fund's clients. Report the longest duration alongside the maximum drawdown, and say whether the current drawdown has recovered yet. A drawdown still open at the end of the data has an unknown duration: count it up to the last date and mark it as unrecovered.
Two other measures are common:
- Time to recovery (trough to recovery) shows how quickly the strategy makes losses back.
- The share of time underwater is the proportion of all dates spent below a previous high. The simulated strategy in the demo ends five years 80% up, yet closes below its previous high on 93% of trading days, because most of those days are small dips just under a recent high.
Underwater chart: drawdown over time
An underwater chart plots the drawdown on every date as a negative area below a zero line, so you can see every loss at a glance and compare it with the others.
It is the bottom panel of the diagram above and of the live demo further down. The zero line is the "surface": the account is at a new high when the chart touches it, and "underwater" whenever it's below. To read one:
- The deepest point is the maximum drawdown. A horizontal line at that level makes it easy to see how close other drawdowns came.
- The width of each dip is that drawdown's duration. Wide, shallow dips are long flat spells; narrow, deep ones are sharp losses that recovered quickly.
- The number of dips shows how often the strategy gives back gains.
- Two strategies' underwater charts on the same axes show which had the deeper losses and whether they lost money at the same time.
An underwater chart is an area chart whose baseline is at the top. It shows drawdowns more clearly than the equity curve, especially after years of growth when a 20% fall is a small wiggle on a linear axis.
Why losses need larger gains to recover
After a loss of , the gain needed to get back to the peak is , which grows much faster than the loss.
A 50% loss halves the account, and doubling what is left (a 100% gain) is needed to recover. The table also shows how many years recovery takes at a steady 8% or 10% a year, calculated as :
| Loss from peak | Gain needed to recover | Years to recover at 8% a year | Years to recover at 10% a year |
|---|---|---|---|
| 10% | 11.1% | 1.4 | 1.1 |
| 20% | 25.0% | 2.9 | 2.3 |
| 25% | 33.3% | 3.7 | 3.0 |
| 30% | 42.9% | 4.6 | 3.7 |
| 40% | 66.7% | 6.6 | 5.4 |
| 50% | 100% | 9.0 | 7.3 |
| 60% | 150% | 11.9 | 9.6 |
| 75% | 300% | 18.0 | 14.5 |
| 90% | 900% | 29.9 | 24.2 |
Because of this asymmetry, risk limits are often set on drawdown, with position sizes cut once a loss reaches a set level. Turn on the crash in the demo to see it: with a 30% market fall added in year two, the strategy's maximum drawdown deepens from 24.1% to 44.1%, and it takes over four years (1,028 trading days) to get back to its old high.
Drawdown ratios: Calmar, Sharpe and Sortino
Risk-adjusted ratios divide return by a measure of risk; the Calmar ratio uses maximum drawdown as that measure.
A strategy returning 12% a year with a 20% maximum drawdown has a Calmar ratio of 0.12 / 0.20 = 0.6. Terry Young, who introduced it in 1991, used the latest 36 months of monthly data; the MAR ratio is the same calculation over the whole history. The live demo on this page uses the whole five years and the compound annual growth rate (CAGR), so strictly its figure is the MAR form.
The Sharpe ratio divides the average return above a risk-free rate by the standard deviation of returns, so it treats rises and falls alike. The Sortino ratio replaces the standard deviation with downside deviation, which counts only returns below a target, so a strategy is not penalised for large gains. Neither looks at the order of returns. The same daily returns shuffled into a different order give the same Sharpe and Sortino ratios but a different maximum drawdown, so drawdown figures are usually reported alongside them.
| Measure | Return part | Risk part | What it misses |
|---|---|---|---|
| Calmar ratio | Annual return (36 months) | Maximum drawdown | All drawdowns except the worst one |
| MAR ratio | CAGR since inception | Maximum drawdown since inception | Same, and it falls as the history lengthens |
| Sharpe ratio | Mean return above the risk-free rate | Standard deviation of returns | The order of returns, and the difference between gains and losses |
| Sortino ratio | Mean return above a target | Downside deviation | The order of returns |
Maximum drawdown tends to get deeper the longer a strategy runs, because a longer history has more chances for a bad stretch (Magdon-Ismail and colleagues give the expected maximum drawdown of a random walk as a function of time). Compare drawdowns and Calmar ratios only over periods of the same length.
How to read an equity curve
Read an equity curve for its slope, its smoothness and its changes in behaviour, not just where it ends.
- Check the scale. On a linear axis, recent moves look bigger than early ones. Switch to a log scale before judging long-run growth.
- Read the slope as the growth rate. On a log axis, a steady slope is steady compound growth; a flattening slope is a fading return.
- Look at the dips below the running peak. Their depth is drawdown, their width is duration. The underwater chart shows the same thing more clearly.
- Look for regime changes: a point after which the curve's slope or roughness changes. In the demo, the strategy's edge fades in year four (no drift and 40% more volatility), and the curve goes flat and jagged. A real regime change might be a change in the market, in costs, or in the strategy's capacity.
- Compare with the benchmark over the same dates. A strategy that rises with the market and falls with it may simply be holding the market.
- Count the data behind it. A smooth curve from twenty trades says much less than one from two thousand.
This page explains how equity curves and drawdown charts are read and built. It is not investment advice.
Why a backtest that looks too good is a warning
A backtest equity curve that rises in a near-straight line with tiny drawdowns is often a sign of a flawed test.
- Overfitting (backtest overfitting): trying many parameter settings or rules and keeping the best makes the winner fit past noise, so it does worse on new data. Bailey, Borwein, López de Prado and Zhu show that with enough trials a high in-sample Sharpe ratio is easy to find by chance.
- Look-ahead bias: the test uses information that was not available at the time, such as a day's closing price to trade at that day's open, or figures that were revised after publication.
- Survivorship bias: the test universe includes only assets that still exist, leaving out companies or funds that failed, which inflates past returns.
- Missing costs: commissions, spreads, slippage and financing are left out or underestimated, which matters most for strategies that trade often.
Testing on data the rules never saw, and recording how many variations were tried, helps to catch these. Even so, live drawdowns are often deeper than a backtest's, for the reasons above.
Comparing two strategies
Compare equity curves over the same dates, from the same starting value, on a log scale, and look at drawdown as well as return.
With the demo's default settings, over the same five simulated years:
| Measure | Strategy | Benchmark |
|---|---|---|
| Total return | 80.2% | 46.8% |
| CAGR | 12.5% | 8.0% |
| Maximum drawdown | 24.1% | 19.0% |
| Longest drawdown (trading days) | 467 | 309 |
| Calmar ratio (whole period) | 0.52 | 0.42 |
The strategy grew faster but fell further and stayed below its old high for longer. Its Calmar ratio is a little higher, so it earned more return for each point of worst-case loss. Whether it is the better choice depends on whether its holders could sit through 467 trading days without a new high. With the crash turned on, both curves change a lot: the benchmark's return drops to 2.8% and the strategy's maximum drawdown to 44.1%, which shows how much these figures depend on one event.
Also check whether the two strategies' drawdowns happen at the same time. Two strategies whose losses don't overlap combine into a smoother curve than either alone.
Common drawdown and equity curve mistakes
Most mistakes with drawdown come from measuring it on the wrong data or over the wrong period.
- Measuring from the starting value. Drawdown is measured from the running peak, not from the initial deposit. An account that rose to $150,000 and fell to $110,000 is in a 26.7% drawdown even though it is still above its $100,000 start.
- Using month-end data for a daily strategy. Lows between month-ends are missed, so drawdowns look shallower than they were.
- Counting deposits and withdrawals as returns. Cash flows move the account balance; drawdown should be computed from returns or a unitised value.
- Quoting only the maximum drawdown. One number hides how often the account loses and for how long. Report the duration and show the underwater chart.
- Comparing drawdowns over different lengths of history. A ten-year record will usually show a deeper maximum drawdown than a two-year record of the same strategy.
- Judging a long equity curve on a linear axis. Early losses look small and recent ones large. Use a log scale.
- Treating a backtest's maximum drawdown as the worst case. It is the worst that happened in one sample of history; live trading can and often does go deeper.
How to create a drawdown chart in JavaScript, React or Angular
The demo below simulates 1,261 trading days of a strategy and a benchmark and recomputes both equity curves, the running peak, both underwater series and the readout from scratch each time you change a setting.
Move Strategy volatility and Drift to change the strategy's daily returns; the random draws stay the same, so only the setting you change moves the curve. Tick Add a crash to put a 30% fall into year two for both curves, Log scale to switch the value axis, and Compare to benchmark to show or hide the benchmark. The maximum drawdown is shaded from its peak to its recovery, with the three points marked. Scroll to zoom, drag to pan, double-click to reset, and hover for values; the two charts stay on the same dates.
Here is the code for this demo. The drawdown maths is plain JavaScript; SciChart.js draws the equity lines, the underwater area and the annotations. The React and Angular versions below draw an equity curve and its underwater chart from your own values.
- JavaScript
- React
- Angular
// An equity curve with its running peak, and an underwater (drawdown) chart below it, with SciChart.js
const {
SciChartSurface,
SciChartVerticalGroup,
NumericAxis,
LogarithmicAxis,
DateTimeNumericAxis,
NumberRange,
EAutoRange,
ENumericFormat,
EXyDirection,
ECoordinateMode,
EHorizontalAnchorPoint,
EVerticalAnchorPoint,
ELabelPlacement,
FastLineRenderableSeries,
FastMountainRenderableSeries,
XyScatterRenderableSeries,
EllipsePointMarker,
XyDataSeries,
BoxAnnotation,
TextAnnotation,
HorizontalLineAnnotation,
SciChartJsNavyTheme,
LegendModifier,
ELegendPlacement,
ELegendOrientation,
CursorModifier,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier,
Thickness
} = SciChart;
// or, for npm, import { SciChartSurface, ... } from "scichart"
// --- Drawdown maths (plain JavaScript) ---
// Running peak, drawdown from that peak, the maximum drawdown with its peak, trough and recovery, the longest
// time below a previous peak, and the summary ratios
function drawdownStats(equity) {
const runningPeak = [];
const drawdown = []; // 0 at a new high, negative below it (-0.25 = 25% below the peak)
let peak = equity[0];
let peakIndex = 0;
let maxDrawdown = 0;
let maxPeakIndex = 0;
let troughIndex = 0;
let longest = 0; // trading days from a peak until the account first gets back to it
for (let i = 0; i < equity.length; i++) {
if (equity[i] >= peak) {
longest = Math.max(longest, i - peakIndex);
peak = equity[i];
peakIndex = i;
}
runningPeak.push(peak);
drawdown.push(equity[i] / peak - 1);
if (drawdown[i] < maxDrawdown) {
maxDrawdown = drawdown[i];
maxPeakIndex = peakIndex;
troughIndex = i;
}
}
const stillUnderwater = equity.length - 1 - peakIndex; // a drawdown that hasn't ended yet counts too
longest = Math.max(longest, stillUnderwater);
let recoveryIndex = -1; // -1: not recovered by the end of the data
for (let i = troughIndex; i < equity.length; i++) {
if (equity[i] >= equity[maxPeakIndex]) {
recoveryIndex = i;
break;
}
}
const years = (equity.length - 1) / TRADING_DAYS_PER_YEAR;
const growth = equity[equity.length - 1] / equity[0];
const cagr = Math.pow(growth, 1 / years) - 1; // compound annual growth rate
return {
runningPeak,
drawdown,
maxDrawdown,
peakIndex: maxPeakIndex,
troughIndex,
recoveryIndex,
longest,
totalReturn: growth - 1,
cagr,
calmar: maxDrawdown < 0 ? cagr / -maxDrawdown : NaN // Calmar ratio over the whole period
};
}
// --- The charts ---
const theme = new SciChartJsNavyTheme();
const group = new SciChartVerticalGroup(); // lines up the two charts' y-axes
const COLOURS = { strategy: "#50C7E0", peak: "#F6E05E", benchmark: "#F48420", drawdown: "#EF5350" };
const percent = (value, digits = 1) => `${(value * 100).toFixed(digits)}%`.replace("-", "−");
const dollars = (value) => `$${Math.round(value).toLocaleString("en-US")}`;
const modifiers = () => [
new CursorModifier({ showTooltip: true, modifierGroup: "drawdown" }),
new MouseWheelZoomModifier({ xyDirection: EXyDirection.XDirection }),
new ZoomPanModifier({ xyDirection: EXyDirection.XDirection }),
new ZoomExtentsModifier({ xyDirection: EXyDirection.XDirection }),
new LegendModifier({ placement: ELegendPlacement.TopLeft, orientation: ELegendOrientation.Horizontal, showCheckboxes: false })
];
// 1. Equity curves: account value over time, with the strategy's running peak
const top = await SciChartSurface.create(ui.equityDiv, { theme });
const topX = new DateTimeNumericAxis(top.wasmContext);
top.sciChartSurface.xAxes.add(topX);
// The value axis can be linear or logarithmic. On a log axis, equal heights are equal percentage changes.
function makeValueAxis(isLog) {
const options = {
axisTitle: isLog ? "Account value (log scale)" : "Account value",
autoRange: EAutoRange.Always,
growBy: new NumberRange(0.1, 0.3), // room above the curves for the legend and labels
labelPrefix: "$",
labelFormat: ENumericFormat.Engineering, // $10K, $12.5K ...
labelPrecision: 1
};
return isLog ? new LogarithmicAxis(top.wasmContext, { ...options, logBase: 2 }) : new NumericAxis(top.wasmContext, options);
}
top.sciChartSurface.yAxes.add(makeValueAxis(false));
const strategyData = new XyDataSeries(top.wasmContext, { dataSeriesName: "Strategy", isSorted: true });
const peakData = new XyDataSeries(top.wasmContext, { dataSeriesName: "Running peak", isSorted: true });
const benchmarkData = new XyDataSeries(top.wasmContext, { dataSeriesName: "Benchmark", isSorted: true });
const markerData = new XyDataSeries(top.wasmContext, { dataSeriesName: "Max drawdown: peak, trough, recovery" });
const benchmarkLine = new FastLineRenderableSeries(top.wasmContext, { dataSeries: benchmarkData, stroke: COLOURS.benchmark, strokeThickness: 1.5 });
top.sciChartSurface.renderableSeries.add(
benchmarkLine,
new FastLineRenderableSeries(top.wasmContext, { dataSeries: peakData, stroke: COLOURS.peak, strokeThickness: 1.5, strokeDashArray: [6, 4] }),
new FastLineRenderableSeries(top.wasmContext, { dataSeries: strategyData, stroke: COLOURS.strategy, strokeThickness: 2 }),
new XyScatterRenderableSeries(top.wasmContext, {
dataSeries: markerData,
pointMarker: new EllipsePointMarker(top.wasmContext, { width: 11, height: 11, fill: "#FFFFFF", stroke: COLOURS.drawdown, strokeThickness: 2 })
})
);
top.sciChartSurface.chartModifiers.add(...modifiers());
// 2. Underwater chart: drawdown from the running peak, as a negative area below zero
const bottom = await SciChartSurface.create(ui.underwaterDiv, { theme });
const bottomX = new DateTimeNumericAxis(bottom.wasmContext);
bottom.sciChartSurface.xAxes.add(bottomX);
const drawdownAxis = new NumericAxis(bottom.wasmContext, {
axisTitle: "Drawdown",
autoRange: EAutoRange.Always,
growBy: new NumberRange(0.08, 0.35) // room above 0% for the legend
});
// Drawdown is never above 0%, so leave the space above zero unlabelled
drawdownAxis.labelProvider.formatLabel = (value) => (value > 0.001 ? "" : `${value.toFixed(0)}%`.replace("-", "−"));
bottom.sciChartSurface.yAxes.add(drawdownAxis);
const strategyDrawdown = new XyDataSeries(bottom.wasmContext, { dataSeriesName: "Strategy drawdown", isSorted: true });
const benchmarkDrawdown = new XyDataSeries(bottom.wasmContext, { dataSeriesName: "Benchmark drawdown", isSorted: true });
const benchmarkUnderwater = new FastLineRenderableSeries(bottom.wasmContext, {
dataSeries: benchmarkDrawdown,
stroke: COLOURS.benchmark,
strokeThickness: 1.5
});
bottom.sciChartSurface.renderableSeries.add(
new FastMountainRenderableSeries(bottom.wasmContext, {
dataSeries: strategyDrawdown,
zeroLineY: 0, // fill between the line and 0%, so the area hangs below zero
fill: COLOURS.drawdown + "66",
stroke: COLOURS.drawdown,
strokeThickness: 1.5
}),
benchmarkUnderwater
);
bottom.sciChartSurface.chartModifiers.add(...modifiers());
// Line up the y-axes and keep both charts on the same dates when you zoom or pan either one
group.addSurfaceToGroup(top.sciChartSurface);
group.addSurfaceToGroup(bottom.sciChartSurface);
const link = (from, to) =>
from.visibleRangeChanged.subscribe(({ visibleRange }) => {
if (!to.visibleRange.equals(visibleRange)) to.visibleRange = visibleRange;
});
link(topX, bottomX);
link(bottomX, topX);
// The year-4 regime change, shaded on both charts
for (const surface of [top.sciChartSurface, bottom.sciChartSurface]) {
surface.annotations.add(
new BoxAnnotation({
x1: dates[REGIME.from],
x2: dates[REGIME.to],
yCoordinateMode: ECoordinateMode.Relative,
y1: 0,
y2: 1,
fill: "#FFFFFF12",
strokeThickness: 0
})
);
}
top.sciChartSurface.annotations.add(
new TextAnnotation({
x1: dates[REGIME.from],
y1: 1,
yCoordinateMode: ECoordinateMode.Relative,
text: "Regime change: edge fades",
fontSize: 12,
textColor: "#C8D3E6",
horizontalAnchorPoint: EHorizontalAnchorPoint.Left,
verticalAnchorPoint: EVerticalAnchorPoint.Bottom
})
);
// Annotations that move with the data: the max drawdown period, its points and labels
let marks = { top: [], bottom: [] };
function markMaxDrawdown(equity, stats, crash) {
marks.top.forEach((annotation) => top.sciChartSurface.annotations.remove(annotation, true));
marks.bottom.forEach((annotation) => bottom.sciChartSurface.annotations.remove(annotation, true));
const { peakIndex, troughIndex, recoveryIndex, maxDrawdown } = stats;
const endIndex = recoveryIndex >= 0 ? recoveryIndex : equity.length - 1;
const period = () =>
new BoxAnnotation({
x1: dates[peakIndex],
x2: dates[endIndex],
yCoordinateMode: ECoordinateMode.Relative,
y1: 0,
y2: 1,
fill: COLOURS.drawdown + "22",
strokeThickness: 0
});
const label = (index, y, text, below) =>
new TextAnnotation({
x1: dates[index],
y1: y,
text,
fontSize: 13,
textColor: "#FFFFFF",
background: "#14233CCC",
padding: new Thickness(2, 4, 2, 4),
// above a point: centred; below the trough: to its right, clear of the crash label
horizontalAnchorPoint: below ? EHorizontalAnchorPoint.Left : EHorizontalAnchorPoint.Center,
verticalAnchorPoint: below ? EVerticalAnchorPoint.Top : EVerticalAnchorPoint.Bottom,
yCoordShift: below ? 8 : -8
});
marks.top = [
period(),
label(peakIndex, equity[peakIndex], `Peak ${dollars(equity[peakIndex])}`, false),
label(troughIndex, equity[troughIndex], `Trough ${percent(maxDrawdown)}`, true),
recoveryIndex >= 0
? label(recoveryIndex, equity[recoveryIndex], "Recovered", false)
: label(endIndex, equity[endIndex], "Not yet recovered", false)
];
if (crash) {
marks.top.push(
new TextAnnotation({
x1: dates[CRASH.from],
y1: 1,
yCoordinateMode: ECoordinateMode.Relative,
text: "Crash",
fontSize: 12,
textColor: "#C8D3E6",
horizontalAnchorPoint: EHorizontalAnchorPoint.Right,
verticalAnchorPoint: EVerticalAnchorPoint.Bottom
})
);
}
marks.bottom = [
period(),
new HorizontalLineAnnotation({
y1: maxDrawdown * 100,
stroke: "#FFFFFF",
strokeThickness: 1,
strokeDashArray: [4, 4],
showLabel: true,
labelPlacement: ELabelPlacement.TopRight,
labelValue: `Max drawdown ${percent(maxDrawdown)}`,
axisLabelFill: "#FFFFFF"
})
];
top.sciChartSurface.annotations.add(...marks.top);
bottom.sciChartSurface.annotations.add(...marks.bottom);
markerData.clear();
markerData.appendRange(
[peakIndex, troughIndex, endIndex].map((i) => dates[i]),
[peakIndex, troughIndex, endIndex].map((i) => equity[i])
);
}
// --- The controls: simulate, measure and redraw ---
function update() {
const settings = {
drift: Number(ui.drift.value) / 100,
volatility: Number(ui.volatility.value) / 100,
crash: ui.crash.checked
};
ui.driftOut.textContent = `${ui.drift.value}% a year`;
ui.volatilityOut.textContent = `${ui.volatility.value}% a year`;
const strategy = simulateEquity(strategyNoise, { ...settings, regimeChange: true });
const benchmark = simulateEquity(benchmarkNoise, { drift: 0.07, volatility: 0.16, crash: settings.crash, regimeChange: false });
const s = drawdownStats(strategy);
const b = drawdownStats(benchmark);
const fill = (dataSeries, values) => {
dataSeries.clear();
dataSeries.appendRange(dates, values);
};
fill(strategyData, strategy);
fill(peakData, s.runningPeak);
fill(benchmarkData, benchmark);
fill(strategyDrawdown, s.drawdown.map((d) => d * 100));
fill(benchmarkDrawdown, b.drawdown.map((d) => d * 100));
markMaxDrawdown(strategy, s, settings.crash);
const compare = ui.benchmark.checked;
benchmarkLine.isVisible = compare;
benchmarkUnderwater.isVisible = compare;
top.sciChartSurface.zoomExtents();
bottom.sciChartSurface.zoomExtents();
// The readout: the figures behind the charts, all computed above
const cell = "padding:3px 10px; text-align:right; border-bottom:1px solid #3a5480;";
const row = (name, stats, colour) =>
`<tr><th scope="row" style="${cell}text-align:left; color:${colour}">${name}</th>` +
`<td style="${cell}">${percent(stats.totalReturn)}</td><td style="${cell}">${percent(stats.cagr)}</td>` +
`<td style="${cell}">${percent(stats.maxDrawdown)}</td><td style="${cell}">${stats.longest}</td>` +
`<td style="${cell}">${Number.isFinite(stats.calmar) ? stats.calmar.toFixed(2).replace("-", "−") : "–"}</td></tr>`;
ui.readout.innerHTML =
`<table style="border-collapse:collapse"><caption style="text-align:left; padding-bottom:4px">` +
`Five simulated years from ${dollars(START_VALUE)}. Longest drawdown is in trading days, from a peak until the account is back at it.</caption>` +
`<tr><td></td><th scope="col" style="${cell}">Total return</th><th scope="col" style="${cell}">CAGR</th>` +
`<th scope="col" style="${cell}">Max drawdown</th><th scope="col" style="${cell}">Longest drawdown</th>` +
`<th scope="col" style="${cell}">Calmar ratio</th></tr>` +
row("Strategy", s, COLOURS.strategy) +
(compare ? row("Benchmark", b, COLOURS.benchmark) : "") +
`</table>`;
}
// Swap the value axis between linear and log; the series keep their data
function setLogScale(isLog) {
const oldAxis = top.sciChartSurface.yAxes.get(0);
top.sciChartSurface.yAxes.remove(oldAxis, true);
top.sciChartSurface.yAxes.add(makeValueAxis(isLog));
top.sciChartSurface.zoomExtents();
}
ui.volatility.addEventListener("input", update);
ui.drift.addEventListener("input", update);
ui.crash.addEventListener("change", update);
ui.benchmark.addEventListener("change", update);
ui.log.addEventListener("change", () => setLogScale(ui.log.checked));
update();
import { SciChartReact, SciChartGroup } from "scichart-react";
import {
SciChartSurface,
SciChartVerticalGroup,
DateTimeNumericAxis,
NumericAxis,
FastLineRenderableSeries,
FastMountainRenderableSeries,
XyDataSeries,
SciChartJsNavyTheme,
CursorModifier,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier,
EXyDirection
} from "scichart";
// Running peak and drawdown (0 at a new high, -0.25 = 25% below it), in one pass
const drawdowns = (values: number[]) => {
let peak = values[0];
const runningPeak = values.map((v) => (peak = Math.max(peak, v)));
return { runningPeak, drawdown: values.map((v, i) => v / runningPeak[i] - 1) };
};
const group = new SciChartVerticalGroup(); // lines up the two charts' y-axes
const { dates, values } = getYourEquityData(); // dates as Unix seconds, account values
const makeChart = (draw: (wasmContext: any, surface: SciChartSurface) => void) => async (root: string | HTMLDivElement) => {
const { wasmContext, sciChartSurface } = await SciChartSurface.create(root, { theme: new SciChartJsNavyTheme() });
sciChartSurface.xAxes.add(new DateTimeNumericAxis(wasmContext));
draw(wasmContext, sciChartSurface);
sciChartSurface.chartModifiers.add(
new CursorModifier({ showTooltip: true, modifierGroup: "drawdown" }),
new MouseWheelZoomModifier({ xyDirection: EXyDirection.XDirection }),
new ZoomPanModifier({ xyDirection: EXyDirection.XDirection }),
new ZoomExtentsModifier()
);
group.addSurfaceToGroup(sciChartSurface);
return { sciChartSurface };
};
const { runningPeak, drawdown } = drawdowns(values);
const equityChart = makeChart((wasmContext, surface) => {
surface.yAxes.add(new NumericAxis(wasmContext, { axisTitle: "Account value", labelPrefix: "$" }));
surface.renderableSeries.add(
new FastLineRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, { xValues: dates, yValues: runningPeak, dataSeriesName: "Running peak" }),
stroke: "#F6E05E",
strokeDashArray: [6, 4]
}),
new FastLineRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, { xValues: dates, yValues: values, dataSeriesName: "Equity" }),
stroke: "#50C7E0",
strokeThickness: 2
})
);
});
const underwaterChart = makeChart((wasmContext, surface) => {
surface.yAxes.add(new NumericAxis(wasmContext, { axisTitle: "Drawdown", labelPostfix: "%" }));
surface.renderableSeries.add(
new FastMountainRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, { xValues: dates, yValues: drawdown.map((d) => d * 100) }),
zeroLineY: 0, // fill up to 0%, so the area hangs below zero
fill: "#EF535066",
stroke: "#EF5350"
})
);
});
export const DrawdownChart = () => (
<SciChartGroup>
<SciChartReact initChart={equityChart} style={{ width: "100%", height: 320 }} />
<SciChartReact initChart={underwaterChart} style={{ width: "100%", height: 200 }} />
</SciChartGroup>
);
import { Component } from "@angular/core";
import { ScichartAngularComponent } from "scichart-angular";
import {
SciChartSurface,
SciChartVerticalGroup,
DateTimeNumericAxis,
NumericAxis,
FastLineRenderableSeries,
FastMountainRenderableSeries,
XyDataSeries,
SciChartJsNavyTheme,
CursorModifier,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier,
EXyDirection
} from "scichart";
// Running peak and drawdown (0 at a new high, -0.25 = 25% below it), in one pass
const drawdowns = (values: number[]) => {
let peak = values[0];
const runningPeak = values.map((v) => (peak = Math.max(peak, v)));
return { runningPeak, drawdown: values.map((v, i) => v / runningPeak[i] - 1) };
};
@Component({
selector: "app-drawdown-chart",
standalone: true,
imports: [ScichartAngularComponent],
template: `
<scichart-angular [initChart]="equityChart" style="display: block; width: 100%; height: 320px"></scichart-angular>
<scichart-angular [initChart]="underwaterChart" style="display: block; width: 100%; height: 200px"></scichart-angular>
`
})
export class DrawdownChartComponent {
private group = new SciChartVerticalGroup(); // lines up the two charts' y-axes
private data = getYourEquityData(); // dates as Unix seconds, account values
private dd = drawdowns(this.data.values);
private makeChart = (draw: (wasmContext: any, surface: SciChartSurface) => void) => async (root: string | HTMLDivElement) => {
const { wasmContext, sciChartSurface } = await SciChartSurface.create(root, { theme: new SciChartJsNavyTheme() });
sciChartSurface.xAxes.add(new DateTimeNumericAxis(wasmContext));
draw(wasmContext, sciChartSurface);
sciChartSurface.chartModifiers.add(
new CursorModifier({ showTooltip: true, modifierGroup: "drawdown" }),
new MouseWheelZoomModifier({ xyDirection: EXyDirection.XDirection }),
new ZoomPanModifier({ xyDirection: EXyDirection.XDirection }),
new ZoomExtentsModifier()
);
this.group.addSurfaceToGroup(sciChartSurface);
return { sciChartSurface };
};
equityChart = this.makeChart((wasmContext, surface) => {
surface.yAxes.add(new NumericAxis(wasmContext, { axisTitle: "Account value", labelPrefix: "$" }));
surface.renderableSeries.add(
new FastLineRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, { xValues: this.data.dates, yValues: this.dd.runningPeak, dataSeriesName: "Running peak" }),
stroke: "#F6E05E",
strokeDashArray: [6, 4]
}),
new FastLineRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, { xValues: this.data.dates, yValues: this.data.values, dataSeriesName: "Equity" }),
stroke: "#50C7E0",
strokeThickness: 2
})
);
});
underwaterChart = this.makeChart((wasmContext, surface) => {
surface.yAxes.add(new NumericAxis(wasmContext, { axisTitle: "Drawdown", labelPostfix: "%" }));
surface.renderableSeries.add(
new FastMountainRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, { xValues: this.data.dates, yValues: this.dd.drawdown.map((d) => d * 100) }),
zeroLineY: 0, // fill up to 0%, so the area hangs below zero
fill: "#EF535066",
stroke: "#EF5350"
})
);
});
}
Key points:
- The running peak, drawdown, maximum drawdown, recovery date and longest duration all come from one pass over the values in plain JavaScript (
drawdownStatsin the demo). - The underwater chart is a FastMountainRenderableSeries with
zeroLineY: 0, so the area fills from the drawdown line up to 0%. The running peak is a FastLineRenderableSeries withstrokeDashArray. - The log toggle swaps the value axis for a
LogarithmicAxis; the series keep their data.labelPrefixandlabelPostfixadd the $ and % to the labels. SciChartVerticalGrouplines up the two charts' y-axes, and each x-axis'svisibleRangeChangedevent sets the other's range, so zooming one chart zooms both. ABoxAnnotation,TextAnnotationandHorizontalLineAnnotationmark the maximum drawdown.
See it in the demo app: JavaScript mountain chart · React mountain chart · Angular mountain chart. Related techniques: the React line chart, React synchronised multi-chart and React chart annotations.
Go deeper: SciChart.js mountain (area) series documentation, the logarithmic axis, synchronising vertical charts, and the learning center guides to the line chart, the area chart and the log scale graph. For the industry, see SciChart for financial and trading applications.
Building a full trading app?
Equity curves and drawdown charts usually sit next to price charts in a trading or portfolio app. SciTrader.js, SciChart's financial charts SDK, provides the price side: candlestick and other price chart types, technical indicators, drawing tools, multiple panes and live data feeds. The performance charts on this page are built with the core SciChart.js API shown above. See what SciChart can do for trading apps on the JavaScript stock charts page. For price-chart basics, read the guides to the candlestick chart and the waterfall chart, which breaks a change in value into its gains and losses.
Frequently asked questions
What is maximum drawdown?
Maximum drawdown (MDD) is the largest fall in an account's or investment's value from a peak to a later low, before a new peak is reached, usually given as a percentage of the peak. If an account rises to $120,000, drops to $90,000 and only then makes a new high, its maximum drawdown is 25%, or $30,000. It measures the worst loss an investor who bought at the top would have sat through.
How do you calculate drawdown?
Keep a running peak: the highest value so far. On each date, drawdown = value / running peak - 1, which is 0 at a new high and negative below it. The maximum drawdown is the most negative of those numbers. For the drawdown in currency, subtract instead: value - running peak.
What is an equity curve?
An equity curve is a line chart of an account's or strategy's value over time, or over its sequence of trades. Traders and fund managers use it to see growth, losing streaks and changes in behaviour at a glance. It is often drawn on a log scale, so equal percentage gains look the same size at any account value.
What is an underwater chart?
An underwater chart plots drawdown over time: how far, in percent, the account is below its previous high on each date. It sits at zero whenever the account makes a new high and drops below zero during losses, usually drawn as a shaded area. The deepest point is the maximum drawdown, and the width of each dip is how long that drawdown lasted.
What is the Calmar ratio?
The Calmar ratio divides a strategy's annual return by its maximum drawdown. As defined by Terry Young in 1991 it uses the latest 36 months of monthly data; the MAR ratio uses the whole history instead. A strategy returning 12% a year with a 20% maximum drawdown has a Calmar ratio of 0.6. Higher means more return for each unit of the worst loss.
How do I plot an equity curve and drawdown chart in JavaScript?
Work out the running peak and the drawdown series in plain JavaScript in one pass over the values. In SciChart.js, draw the equity and the running peak as two FastLineRenderableSeries on a date axis, and the drawdown as a FastMountainRenderableSeries with zeroLineY set to 0 on a second chart below, linked with SciChartVerticalGroup so both share dates when zooming. scichart-react and scichart-angular wrap the same code for React and Angular apps.
Sources
- Magdon-Ismail, M., Atiya, A. F., Pratap, A. and Abu-Mostafa, Y. S. (2004), On the maximum drawdown of a Brownian motion, Journal of Applied Probability, 41(1), 147–161. Derives the expected maximum drawdown of a random walk and how it grows with time.
- Young, T. W. (1991), Calmar ratio: a smoother tool. Futures, 1 October 1991. Defines the Calmar ratio as the average annual return over the latest 36 months divided by the maximum drawdown over the same 36 months, measured monthly.
- Sharpe, W. F. (1994), The Sharpe ratio, The Journal of Portfolio Management, 21(1), 49–58.
- Sortino, F. A. and Price, L. N. (1994), Performance measurement in a downside risk framework, The Journal of Investing, 3(3), 59–64.
- Bailey, D. H., Borwein, J. M., López de Prado, M. and Zhu, Q. J. (2014), Pseudo-mathematics and financial charlatanism: the effects of backtest overfitting on out-of-sample performance, Notices of the American Mathematical Society, 61(5), 458–471.
- Brown, S. J., Goetzmann, W., Ibbotson, R. G. and Ross, S. A. (1992), Survivorship bias in performance studies, The Review of Financial Studies, 5(4), 553–580.