TradingView Backtesting

Time-Weighted vs Money-Weighted Returns for Trading Journals

Time-weighted return (TWR) links the returns earned between deposits and withdrawals, removing their direct effect on account growth. Money-weighted return measures the return on the capital you actually supplied, including when you supplied it. A trading journal can report both: TWR helps compare investment performance, while money-weighted return explains your funding experience. A trade CSV alone is not a complete account cash-flow ledger.

See the decision guide

Build the account ledger before calculating a return

This hypothetical USD account has exactly three 365-day periods. Values include cash and all open positions at market value. Each flow occurs at the stated boundary, immediately after the preceding valuation and before the next period begins. There are no other external flows. All values use one consistent fee and tax basis; no extra costs are added in the arithmetic below.

  • The dollar gain is $14,300 + $5,000 - $10,000 - $9,000 = $300. This reconciles the ledger but does not by itself define a percentage return.
  • Purchasing or selling a security inside this account exchanges cash and holdings. It is not an external account flow. Transfers across the account boundary are external flows, including securities transferred in kind at their value.
  • Dividends and interest retained inside the account contribute to investment return. If paid out of the account, record the payout consistently as an external withdrawal without removing the earned income from performance.
Boundary dateValue before flowExternal flow into accountValue after flow
2021-01-01: start$10,000Opening value, not an extra flow$10,000
2022-01-01$11,000+$9,000 deposit$20,000
2023-01-01$18,000-$5,000 withdrawal$13,000
2024-01-01: end$14,300$0$14,300

Calculate time-weighted return by linking the subperiods

For each interval without an external flow, r = ending value before the next flow / starting value after the previous flow - 1. Then TWR = product of (1 + r) - 1. These are geometric growth factors; averaging or adding the percentages gives a different result. The flow-boundary method follows the CFA Institute GIPS calculation guidance linked below.

  • A hypothetical $10,000 exposed to the same percentage returns without external flows would finish at $10,890. This assumes funding does not change the realized strategy returns.
  • The arithmetic sum, 10% - 10% + 10% = 10%, is not the compound return. The raw balance change, $14,300 / $10,000 - 1 = 43%, incorrectly includes net funding.
IntervalCalculationReturn
2021-01-01 to 2022-01-01$11,000 / $10,000 - 1+10%
2022-01-01 to 2023-01-01$18,000 / $20,000 - 1-10%
2023-01-01 to 2024-01-01$14,300 / $13,000 - 1+10%
Full period1.10 × 0.90 × 1.10 - 1+8.9000%
Annualized over 1,095 days1.089^(365 / 1095) - 1+2.8828%

Calculate money-weighted return with IRR or XIRR

Here money-weighted return means the internal rate of return (IRR). Use the investor perspective: money supplied to the account is negative; money received is positive. Treat the ending account value as a terminal receipt for measurement, even if you keep the account open. Some reports use Modified Dietz under the money-weighted label, so check the stated method before comparing numbers.

  • Excel XIRR uses actual dates and a 365-day year. IRR(B2:B5) also gives the annual result in this example because the flows are exactly one year apart; use XIRR for irregular dates.
  • The investor added $9,000 just before the losing interval and withdrew $5,000 before the final gain. More capital experienced the loss, so the annual money-weighted result is below the annual TWR.
  • Compare 0.6933% annual IRR with 2.8828% annual TWR, or compare their full-period equivalents. Comparing annual IRR with cumulative TWR mixes time bases.
Spreadsheet rowA: dateB: investor cash flow
22021-01-01-10000
32022-01-01-9000
42023-01-015000
52024-01-0114300
Enter A2:A5 as actual spreadsheet dates and B2:B5 as numbers. Format return cells as percentages.text
Annual money-weighted return:
=XIRR(B2:B5,A2:A5)
Result: 0.6933071%

Equivalent return over these 1,095 days:
=(1+XIRR(B2:B5,A2:A5))^((A5-A2)/365)-1
Result: 2.0943747%

Independent check with annual rate r:
0 = -10000 - 9000/(1+r) + 5000/(1+r)^2 + 14300/(1+r)^3
r = 0.006933070609156

Use Modified Dietz when flow-date valuations are missing

Modified Dietz weights each external flow by the fraction of the measurement period remaining. It needs starting and ending values plus dated flows, without a valuation at each flow. For this ledger, use the account perspective again: deposits are positive and withdrawals negative. The formula is R = (ending value - starting value - sum of flows) / (starting value + sum of weighted flows).

  • The 2.0930% result is a full-period estimate. It happens to be close to the 2.0944% full-period IRR equivalent in this example. It does not reproduce the 8.9000% TWR.
  • One whole-period Dietz result is a money-weighted approximation. Linking shorter Dietz periods can approximate TWR; valuation at every external flow gives the exact segmentation used above.
  • For daily records, choose and document a beginning-of-day or end-of-day flow convention. Large flows during volatile periods make an approximation less dependable. Obtain flow-date valuations when that difference matters.
Full-period Modified Dietz, using elapsed-day weightstext
Total elapsed days D = 1095
Deposit occurs at day 365: weight = (1095 - 365) / 1095 = 2/3
Withdrawal occurs at day 730: weight = (1095 - 730) / 1095 = 1/3

Gain = 14300 - 10000 - (9000 - 5000) = 300
Weighted capital = 10000 + 9000*(2/3) - 5000*(1/3)
                 = 14333.333333
Modified Dietz = 300 / 14333.333333 = 2.0930233%

Interpret the gap without treating it as trading skill

TWR removes the direct accounting effect of external funding. It still reflects the actual portfolio holdings, cash allocation, trading costs and market exposure. Money-weighted return combines those investment results with funding timing. A gap between the two describes this account history; it does not prove that the trader can time future deposits or that a strategy has an edge.

Question in the journalMeasure to reportComparison constraint
How did the portfolio perform across periods?TWR, with valuation and flow conventionMatch the benchmark dates, currency, income treatment and fee basis.
What return did my contributed capital experience?Money-weighted IRR/XIRRInclude every external flow and the full ending account value.
What can I estimate without interim valuations?Modified Dietz, explicitly labeledRetain dated flows and disclose that it is an approximation.
How much money did the account earn?Ending value + withdrawals - deposits - opening valueThis dollar amount is not a risk-adjusted or annualized return.

Handle missing records and invalid denominators

A return is only as complete as its ledger. Reconcile broker statements, transfers and valuations before investigating a discrepancy with a journal. Use one reporting currency and translate each flow at its date; include unrealized positions and accrued amounts consistently in account values.

  • If a TWR subperiod starts at zero, its percentage return is undefined. An account emptied and later funded needs a documented restart policy. Negative equity requires a method appropriate to that account, not an unqualified positive-capital formula.
  • Modified Dietz is undefined when weighted capital is zero and can become misleading when the denominator is very small or negative.
  • XIRR needs positive and negative values and valid paired dates. A failed solver is not a zero return. Cash flows with repeated sign changes can admit multiple IRRs; inspect the roots and the underlying cash flows rather than accepting whichever root a guess finds.
  • Without valuations at the cash-flow boundaries, do not label an estimated TWR as exact. Without a complete flow ledger, neither XIRR nor Dietz repairs the missing deposits or withdrawals.

Keep TradingView trade analysis separate from account funding

Backtest Deep Report imports TradingView trade CSV files and calculates trade-based results such as net profit, profit factor and drawdown from configured initial capital. Its trade import is not a broker cash-flow ledger, and this page does not claim that the report calculates TWR, XIRR or Modified Dietz. Keep those calculations in a separate account worksheet with statement valuations and external flows.

  • Save the TradingView symbol, period, strategy settings and exported trades together. Compare the report with the same simulation before comparing it with a funded brokerage account.
  • A closed-trade equity curve may omit open-position movement between exits. Do not substitute it for account market values at deposit or withdrawal times.
  • Use Pine Script AI Coding Agent to help draft custom strategy statistics when the required simulated data is available. A custom script cannot recover broker deposits or missing account valuations from a trade export; verify the result against a separate ledger.
Where Pineify fits

Backtest Deep Report

Review net profit, profit factor and drawdown from exported TradingView trades. Calculate account cash-flow returns separately with the ledger and formulas above.

Also useful: Pine Script AI Coding Agent. Draft custom statistics for your simulated strategy, then validate their assumptions and results against an independent calculation.

Analyze exported trades

Frequently asked questions

Educational information, not investment advice. All account values and returns on this page are hypothetical arithmetic examples, not observed trading performance. Return calculations do not establish future profitability or replace broker and accounting records.

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.