TradingView Backtesting

Conditional Drawdown at Risk: Equity-Path Tail Measures

Conditional drawdown at risk (CDaR) averages the worst tail of drawdown observations from an equity curve. At a 95% confidence level, it averages the largest 5% of sampled drawdowns. First construct the chronological equity path and its running peaks, then calculate and rank the drawdowns. An unordered list of returns cannot recover this path risk. This page uses positive percentage drawdowns sampled at each trading-day close.

See the decision guide

Define the equity, sampling and drawdown units

Chekhlov, Uryasev and Zabarankin define CDaR using the underwater curve. Their optimization formulation uses drawdown differences on uncompounded cumulative returns. Here we apply the same tail-average operation to relative drawdowns on a compounded account-equity path. Label that percentage convention explicitly; its values and portfolio-optimization properties should not be silently substituted for the original additive formulation.

  • Use E0 as starting equity. At time t, running peak Pt = max(E0, E1, ..., Et), and relative drawdown Dt = 1 - Et/Pt. A new high has zero drawdown. With positive equity, these magnitudes lie from 0% to below 100%.
  • The example uses one observation per trading-day close, after assumed costs and including open-position valuations. It has no deposits or withdrawals. Starting equity sets the initial peak but is not an extra observation in the eight-day distribution.
  • For cash-flow-adjusted returns rt, a normalized equity index can be constructed as Et = E(t-1) × (1 + rt). A deposit or withdrawal must not be mistaken for investment performance.
  • Absolute drawdown Pt - Et has currency units; dividing by Pt gives the percentage convention used here. Choose one measure, date range and valuation schedule for all strategies being compared.

Construct the drawdown distribution from eight daily closes

Start with hypothetical equity E0 = 100 currency units. The table contains all eight consecutive trading-day closes. Every row has weight 1/8, including days at new or recovered highs. No intraday path is assumed, so these results describe closing equity only.

  • Day 3 drawdown = 1 - 88/110 = 20%. Measuring against initial equity instead would give 12%, which misses the earlier peak.
  • Only after computing chronological peaks, sort the drawdowns descending: 20%, 10%, 10%, 10%, 5%, 0%, 0%, 0%.
  • At alpha = 0.75, the tail size is (1 - alpha) × 8 = 2 observations. CDaR = (20% + 10%)/2 = 15%.
  • Maximum drawdown is 20%. Average daily drawdown is (20 + 10 + 10 + 10 + 5)/8 = 6.875%. The days in one prolonged loss remain separate observations.
Trading dayClosing equity EtRunning peak PtDrawdown Dt
11101100%
29911010%
38811020%
49911010%
51101100%
6104.51105%
79911010%
81101100%

Use fractional tail weights when the cutoff splits a row

For n equally weighted observations and 0 ≤ alpha < 1, define CDaR as min over z of [z + sum(max(Dt - z, 0)) / ((1 - alpha) × n)]. This empirical expected-shortfall definition handles ties and non-integer tail sizes. A plain average of every value above or equal to a percentile can include too much probability mass.

  • At alpha = 0.75, selecting all drawdowns at least 10% would average four rows and return 12.5%. The required worst quarter contains only two rows and returns 15%. Tied 10% rows are interchangeable, but their total tail weight is fixed.
  • At alpha = 0, the formula includes all eight observations and gives 6.875%. As alpha approaches 1, it approaches the maximum. For this finite sample it already equals 20% when the tail contains one observation or less.
  • Do not evaluate the displayed formula at alpha = 1: its denominator is zero. Report maximum drawdown separately as the limiting case. An empty series or an out-of-range alpha is invalid; an all-zero drawdown series has CDaR = 0.
  • For an integer tail size, average exactly that many largest rows. For a fractional tail size, give the boundary row only the remaining weight. Do not round the tail size up or down without declaring a different estimator.
Tail-average calculation on sorted drawdowns, in percentage pointstext
D = [20, 10, 10, 10, 5, 0, 0, 0]  (descending)
n = 8
alpha = 0.80
m = (1 - alpha) * n = 1.6
k = floor(m) = 1
fraction = m - k = 0.6
CDaR = (sum of first k values + fraction * next value) / m
     = (20 + 0.6 * 10) / 1.6
     = 16.25%

The same returns can have different CDaR

Consider four hypothetical daily returns with no cash flows, starting equity 100 and identical costs already included. Path A places both losses first; Path B alternates losses and gains. Both paths contain two -10% days and two +10% days, finish at 98.01, and have 50% daily return-loss CVaR of 10%. Their running-peak losses differ.

  • Single-period return CVaR is unchanged by permuting these observations. CDaR and maximum drawdown depend on the sequence used to construct equity and its peaks.
  • Maximum drawdown keeps only the deepest observation. CDaR averages a specified tail, so several severe underwater days can affect it. It still does not report recovery duration or the chronology of every episode; keep the equity chart alongside the number.
  • This comparison concerns CVaR of daily returns. A different loss variable, such as multi-day cumulative loss, needs its own horizon and distribution.
MeasurePath APath B
Daily return order-10%, -10%, +10%, +10%-10%, +10%, -10%, +10%
Closing equity sequence90, 81, 89.1, 98.0190, 99, 89.1, 98.01
Drawdown sequence10%, 19%, 10.9%, 1.99%10%, 1%, 10.9%, 1.99%
50% CDaR(19% + 10.9%)/2 = 14.95%(10.9% + 10%)/2 = 10.45%
Maximum drawdown19%10.9%
50% CVaR of daily loss = -return(10% + 10%)/2 = 10%(10% + 10%)/2 = 10%

Sampling and missing history can dominate the result

CDaR is conditional on the supplied observations. In the eight-day example, sampling only days 1, 5 and 8 records equity of 110 each time and produces zero drawdown, although the intervening daily path fell 20%. A daily-close calculation can likewise miss an intraday trough.

  • Keep all scheduled observations, including zeros and unfinished drawdowns at the end of the test. Dropping zero rows or waiting only for completed recoveries changes the distribution.
  • Trade exits are irregular events. Giving each exit equal weight estimates a distribution over exits, not time spent underwater. Use a regular valuation grid for the daily convention on this page.
  • State whether the running peak starts at the test boundary or carries an earlier high. Resetting the peak can hide a drawdown already in progress.
  • Resolve missing valuations and external cash flows before calculating. This workflow requires positive equity; zero or negative equity needs separate treatment of capital loss and financing.
  • A 95% tail in 20 daily observations contains only one observation and equals the sample maximum. A high confidence level does not compensate for a short or unrepresentative history.
  • Do not annualize CDaR with a square-root rule. Compare matching horizons, frequencies, leverage and cost assumptions, and examine a separate evaluation period. Historical CDaR is not a promised future loss limit.

Use TradingView CSV reports without inventing daily equity

TradingView exports each Strategy Report tab separately. A List of Trades CSV contains trade information; the performance export contains metrics. Neither a final summary nor an unordered P&L list supplies the full daily mark-to-market equity path required by this example.

  • Backtest Deep Report accepts TradingView trade CSVs and provides supported profit and risk results. Its equity calculation adds imported trade net P&L to initial capital and associates the resulting points with trade exits. Reconcile the records, ordering and capital settings before comparing drawdowns.
  • The current report does not expose CDaR. Calculate it independently from a complete, chronological equity series with an explicit sampling convention. Do not relabel maximum drawdown or an exit-based curve as daily CDaR.
  • Pine Script AI Coding Agent can help draft a custom statistic when you specify the equity source, sampling time, initial peak, confidence level and fractional-tail rule. Compile and test the generated code, then reconcile its outputs with the examples on this page.
Where Pineify fits

Backtest Deep Report

Import TradingView trade CSVs to review supported profit and drawdown results. Calculate CDaR separately from the equity observations your chosen convention requires.

Also useful: Pine Script AI Coding Agent. Draft custom equity statistics with explicit sampling and tail rules, then validate the generated code against an independent calculation.

Review exported trades

Frequently asked questions

Educational information, not investment advice. All equity paths and returns shown here are hypothetical. Historical drawdown statistics do not guarantee future returns or maximum losses.

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.