TradingView Backtesting

Sterling Ratio for Backtests: Drawdown Definitions Matter

Sterling ratio measures return relative to drawdown, but the name does not identify one universal formula. This page calculates the PerformanceAnalytics convention: compound annual return divided by the full-period maximum drawdown magnitude plus 10 percentage points. It also shows how replacing that maximum with the average annual maximum changes the result on identical equity. Always report the formula, observation frequency and test dates with the ratio.

See the decision guide

Historical and software definitions do not match

The differences extend beyond rounding. Don Chance's 1994 managed-futures monograph prints an adjustment outside the ratio. Fundpeak documents an annual-average drawdown version, while PerformanceAnalytics implements a full-period maximum. These are source-specific definitions, not interchangeable labels for a single number.

  • Ten percentage points means adding 0.10 to a decimal drawdown. With 20% drawdown the denominator becomes 30%, not 22%.
  • If signed annual drawdowns average -0.116667, abs(-0.116667 - 0.10) equals 0.216667. Subtracting 0.10 from the positive magnitude instead gives 0.016667, a different calculation.
  • A version that subtracts a risk-free return, removes the adjustment or averages selected drawdown episodes needs its own label. Do not rank it alongside a different version.
Source or conventionReturn and denominatorAdjustment and boundary
Chance, 1994, printed page 40Average annual return over the past three years / maximum drawdownAdds 0.1 AFTER division. This historical printed formula is not the implementation selected here.
Fundpeak factsheet documentationCompound annual return / adjusted average yearly maximum drawdown; normally the last three yearsPrints average maximum drawdown minus 10%. Its displayed formula does not resolve the drawdown sign convention; confirm that convention before reproducing a report.
PerformanceAnalytics SterlingRatio, selected hereGeometric annualized return / (positive full-period maximum drawdown + excess)Default excess = 0.10. The caller chooses the data window; the function does not enforce three years.
Average-annual sensitivity calculation belowCAGR / (mean of positive annual maximum drawdowns + 0.10)An explicitly defined comparison calculation. It is not a claim that the other sources implement this exact sign convention.

Use one equity path for both drawdown definitions

Assume three complete calendar years, no deposits or withdrawals, and account equity after all assumed costs. Values are hypothetical currency units. Each row gives the chronological observations within that year; assume no unlisted observation exceeds the stated peaks or falls below the trough. Every year ends at a new high, so no drawdown crosses a year boundary in this example.

  • At each observation, peak = highest equity seen so far; drawdown = 1 - equity / peak. The full-period maximum is 20%, not the 12% decline from initial equity of 100 to 88.
  • For the annual-average calculation, initialize each year with its opening equity, calculate that year's running peak and take its worst decline. Average the three magnitudes: (10% + 20% + 5%) / 3 = 11.666667%.
  • CAGR = (133.10 / 100)^(1/3) - 1 = 10%. The cumulative gain is 33.10%; dividing it by three gives 11.033333%, which is not CAGR.
YearStart → trough → recovery → endAnnual returnAnnual maximum drawdown
1100 → 90 → 100 → 110110 / 100 - 1 = 10%(100 - 90) / 100 = 10%
2110 → 88 → 110 → 121121 / 110 - 1 = 10%(110 - 88) / 110 = 20%
3121 → 114.95 → 121 → 133.10133.10 / 121 - 1 = 10%(121 - 114.95) / 121 = 5%

Four labeled calculations, one unchanged backtest

Keep the 10% compound annual return fixed to isolate denominator choices. These rows demonstrate formula sensitivity; they are not a ranking of four strategies. The selected implementation is the first row.

  • The higher annual-average result follows from a smaller denominator. No extra return was earned and the 20% worst loss still occurred.
  • In a spreadsheet, enter 10%, 20% and 5% in B2:B4 and 10% CAGR in B6. Use =B6/(MAX(B2:B4)+10%) and =B6/(AVERAGE(B2:B4)+10%).
  • MAX of annual maxima equals the full-period maximum for this recovered-at-year-end example. It need not do so when each year resets its peak and a loss continues across New Year.
  • Keep full precision through division and format the final ratio as a plain number. A ratio of 0.333333 is not a 33.3333% return.
Formula labelDenominatorCalculationResult
Sterling, full-period maximum + 10 pp20% + 10% = 30%0.10 / 0.300.333333
Annual-average maximum + 10 pp11.666667% + 10% = 21.666667%0.10 / (0.35 / 3 + 0.10)0.461538
Annual-average maximum, no adjustment11.666667%0.10 / (0.35 / 3)0.857143
CAGR / full-period maximum, Calmar-style20%0.10 / 0.200.500000

Annual maxima are not time-average drawdown

Mean annual maximum gives each year one observation: its deepest loss. Averaging all daily underwater values instead weights long drawdowns more heavily. Averaging separate peak-to-recovery episodes gives each episode one observation. Those denominators answer different questions even when drawn from the same equity series.

  • Declare how annual peaks reset. A peak of 100 before New Year, year-end equity of 90 and a later trough of 80 create a 20% continuous drawdown. The new year's reset-peak decline is only (90 - 80) / 90 = 11.111111%.
  • Keep zero-drawdown years in an annual average. Excluding them changes the sample. Specify whether partial years are excluded, retained or weighted; do not silently count a one-month fragment as a full year.
  • Daily closing equity can miss intraday losses. Closed-trade equity can miss losses on open positions. Use the same equity sampling and position valuation rules for every comparison.
  • A single unusually deep loss can be diluted by an annual average. Report the full-period maximum and recovery duration next to any averaged denominator.

Handle zero drawdown, negative growth and invalid equity

With the selected 0.10 adjustment, zero measured drawdown still produces a finite ratio: 10% CAGR / 10% = 1. That result reflects the chosen adjustment and observation history; it does not prove that future losses are limited.

  • Without an adjustment, zero drawdown makes the ratio undefined. Report the numerator and zero denominator instead of turning 0/0 into zero.
  • Negative CAGR produces a negative selected Sterling ratio. For the same -10% CAGR, increasing drawdown from 10% to 30% moves the ratio from -0.5 to -0.25. A value closer to zero does not mean the loss improved.
  • Require positive initial equity, a positive elapsed time and a valid return path. If equity reaches zero or becomes negative, stop this standard compounded-return workflow and report the capital loss and financing assumptions separately.
  • Correct for external cash flows before calculating investment returns. A withdrawal can resemble a drawdown and a deposit can resemble performance.
  • A short backtest, omitted costs or parameter selection on the same history can produce an attractive ratio without evidence that the result will persist. No universal Sterling cutoff establishes a tradable strategy.

Reconcile TradingView exports before adding Sterling

TradingView exports strategy tabs separately. Save the trade list, report dates, initial capital, strategy settings and cost assumptions together. A trade CSV is useful for checking realized profit, but it is not a complete daily mark-to-market account history.

  • Backtest Deep Report accepts TradingView List of Trades CSV files and calculates supported profit and risk results. Its overview equity curve starts with initial capital and adds trade net P&L at exits; drawdown follows that curve.
  • That realized-trade curve can differ from TradingView's intratrade or open-position drawdown. Reconcile the equity definition before substituting a displayed maximum into the formula.
  • The current report does not expose a Sterling ratio field. Calculate the chosen formula separately using the equity observations and annual boundaries you have documented.
  • If custom Pine output is needed, give Pine Script AI Coding Agent the exact formula, equity sampling rule, calendar boundary and zero-denominator policy. Review and syntax-check the generated code, then compare it with the arithmetic example before relying on the output.
Where Pineify fits

Backtest Deep Report

Import a TradingView trade CSV to inspect supported profit and drawdown results. Keep the separately calculated Sterling ratio labeled with its formula and equity definition.

Also useful: Pine Script AI Coding Agent. Specify custom equity statistics and boundary rules, then review and validate the generated Pine Script against a known calculation.

Explore Backtest Deep Report

Frequently asked questions

Educational information, not investment advice. All equity values and returns in the worked examples are hypothetical. Backtested ratios do not guarantee future returns or drawdown limits.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.