TradingView Backtesting

Gain-to-Pain Ratio for Trading Results: Periods and Denominators

The gain-to-pain ratio (GPR) divides the sum of all returns, including losses, by the absolute sum of negative returns. Jack Schwager defines it using monthly returns. With a positive loss denominator, GPR = P/L - 1, where P is the positive-return sum and L is the absolute negative-return sum. It equals profit factor minus one only when both calculations use the same observations, units and costs.

See the decision guide

Define gains, losses and the return period

For observations r₁ through rₙ, let P = sum(max(rᵢ, 0)) and L = sum(max(-rᵢ, 0)). The net sum N = sum(rᵢ) = P - L. Gain-to-pain ratio = N/L when L > 0. Each observation has equal weight; zero returns add nothing to either sum. Using decimals or percentage points gives the same ratio if the scale is consistent.

  • For monthly account returns without external cash flows, r = month-end equity / previous month-end equity - 1. Include the chosen treatment of open positions and costs in both valuations.
  • Use consecutive, non-overlapping periods. Keep genuine zero-return months, resolve missing observations, and adjust deposits or withdrawals before treating equity changes as investment returns.
  • If you choose trade-level dollar P&L instead, label the result as a trade-P&L GPR. Changing trade sizes means trade percentages and dollar outcomes need not produce the same ratio.
  • Report the dates, frequency, number of observations, positive sum, loss sum and fee convention. The word net means positive observations minus negative observations here; it does not automatically prove that brokerage costs were included.

Work through six months without compounding the numerator

Assume these six hypothetical monthly account returns already include trading costs and have no external cash flows. Contributions in the last two columns use percentage points. This is an arithmetic example, not a TradingView strategy result.

  • P = 4 + 3 + 2 = 9 pp; L = 2 + 1 = 3 pp; N = 9 - 3 = 6 pp. GPR = 6/3 = 2.
  • A GPR of 2 means the arithmetic net-return sum is twice the absolute loss sum. It does not mean a 200% account return or twice as many winning months.
  • Compounded growth is 1.04 × 0.98 × 1.03 × 0.99 × 1.00 × 1.02 - 1 = 6.00638048%. Substituting that number into the numerator would change the definition.
  • The distinction can change the sign of the growth conclusion: +10% followed by -10% has GPR = 0, but compounds to -1%. GPR alone does not establish compound profitability.
MonthAccount returnContribution to PContribution to L
1+4%40
2-2%02
3+3%30
4-1%01
50%00
6+2%20
TotalArithmetic sum: +6 pp93

Reproduce the calculation in a spreadsheet

Enter the six monthly returns as percentage values in A2:A7. The formulas below return the net sum, absolute loss sum and ratio. Check that all six cells are numeric first; SUM can ignore missing or text values and silently change the sample.

  • Format GPR as a plain number. The percentage units cancel; a result of 2 is not 2%.
  • The #N/A branch flags a zero denominator for review. It deliberately avoids displaying a large substitute number or calling an all-zero sample profitable.
OutputFormulaExample result
Net arithmetic sum=SUM(A2:A7)6%
Absolute negative-return sum=ABS(SUMIF(A2:A7,"<0",A2:A7))3%
Gain-to-pain ratio=IF(ABS(SUMIF(A2:A7,"<0",A2:A7))=0,NA(),SUM(A2:A7)/ABS(SUMIF(A2:A7,"<0",A2:A7)))2

Why GPR equals profit factor minus one on the same data

A profit-factor-style calculation uses the gross positive sum P as its numerator, while GPR uses the net sum P - L. For L > 0, (P - L)/L = P/L - 1. On identical inputs, these are two presentations of the same evidence and give the same ordering. Counting both as independent confirmation would double-count that evidence.

  • TradingView defines profit factor using realized winning and losing trades; open-position P&L is excluded. Its reported value is not generally P/L computed from monthly account returns.
  • Subtracting one from trade profit factor gives a trade-P&L GPR only if the date window, included trades, currency and cost treatment match. It does not recover a monthly GPR.
  • Gross positive sum here means the total of positive observations. Individual trade observations can already be net of fees. If fees change which trades are winners, recalculate both sums after costs instead of subtracting total fees from only the final ratio.
Identical input seriesPLP/LGPR = (P - L)/L
Six monthly returns above9 pp3 pp32
Closed trades: +$400, -$200, +$300, -$100$700$3002.3333331.333333
Closed trades: +$100, -$200$100$2000.5-0.5

Frequency changes which losses the denominator sees

Suppose a hypothetical month has daily returns of +10% and -9%, with zero returns on its other days. Daily GPR = (10 - 9)/9 = 0.111111. The monthly compounded return is 1.10 × 0.91 - 1 = +0.1%. That one-month sample has no negative month and therefore no finite monthly GPR. Aggregation has hidden the losing day from the monthly denominator.

  • Compare daily with daily and monthly with monthly over matching windows. Monthly sampling can conceal losses that recover before month-end; a daily sample still misses intraday drawdowns.
  • Do not multiply GPR by 12 or sqrt(12) to annualize it. Construct annual returns and recompute both sums if annual observations are the intended question.
  • Dividing both sums by the same total observation count leaves GPR unchanged. Dividing the loss sum by only the number of losing periods produces a different statistic.
  • A common positive scaling of every observation leaves GPR unchanged. Real changes in leverage, financing or position sizing can alter costs and returns unevenly, so that algebra is not evidence that risk is unchanged.

Zero losses and negative ratios need explicit labels

A finite GPR requires L > 0. With that condition, P cannot be negative, so GPR cannot fall below -1. An output below -1 indicates a different definition or a data or sign error. A high value with very little observed loss can be unstable.

  • Some software displays infinity for positive gains with no losses. Treat that as a reporting convention, not a finite performance estimate or proof of zero risk.
  • The ratio ignores observation order. Rearranging returns preserves GPR but can change maximum drawdown and recovery time. Inspect the equity path separately.
  • A short record may omit rare large losses. Schwager specifically cautions that a smooth history can fail to represent a strategy's underlying risks. Report sample length and avoid a universal good-ratio cutoff.
Sample conditionCalculationInterpretation
Positive returns; no lossesP > 0, L = 0No finite ratio; report no observed losses
All returns zero0/0Undefined
No positive returns; at least one loss(0 - L)/L = -1All nonzero observations are losses
Positive and negative sums match(P - L)/L = 0Arithmetic break-even; compound growth may differ
Loss sum exceeds positive sum-1 < GPR < 0Negative arithmetic return sum

Reconcile TradingView exports before calculating a separate GPR

Download the List of Trades CSV for closed-trade reconciliation. TradingView exports each report tab separately, so a Performance Summary download is not the trade list. Backtest Deep Report imports trade CSV files and calculates net profit, gross profit, gross loss and profit factor from parsed closed-trade net P&L.

  • Review the parsed trades and initial capital, then compare the report totals with your export. Its overview drawdown follows closed-trade equity; it does not measure every mark-to-market movement within a trade.
  • The current report does not display a dedicated gain-to-pain metric. For a trade-P&L calculation with gross loss above zero, independently divide its net profit by gross loss and check that this equals its unrounded profit factor minus one.
  • For the monthly definition on this page, prepare month-end account returns separately. A closed-trade CSV alone does not provide every month-end valuation of open positions.
  • Pine Script AI Coding Agent can help draft a custom statistic if you specify the equity series, sampling dates, fees and zero-loss behavior. Review and validate any generated script, then reconcile its output with the worksheet example before using it.
Where Pineify fits

Backtest Deep Report

Import TradingView trade CSV data and review the supported profit and risk results. Keep your independently calculated GPR labeled by its input series.

Also useful: Pine Script AI Coding Agent. Describe a custom return statistic with explicit sampling and denominator rules, then verify the generated code against a known calculation.

Review exported trades

Frequently asked questions

Educational information, not investment advice. All numerical examples are hypothetical. Historical gain-to-pain ratios and backtests do not guarantee future returns or describe every source of risk.

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.