TradingView backtesting

Profit factor: calculation, costs and sample size

Profit factor is total winning-trade P&L divided by the absolute total losing-trade P&L. A value above 1 means those closed trades made money on the cost basis used. There is no universal threshold that makes a strategy good: inspect costs, losses, sample coverage and drawdown before interpreting the ratio.

Worked example

$1,000 ÷ $500 = 2.00

$2 earned in winning trades for every $1 lost. The total P&L is $500, not a 200% account return.

Reviewed October 17, 2026. Examples are hypothetical arithmetic, not observed trading results.

Calculate profit factor from closed trades

Use one currency and one cost convention. Sum positive trade P&L as gross profit. Sum negative trade P&L and take its absolute value as gross loss. Divide the two totals. Here, "gross" names the positive and negative buckets; it does not automatically mean commissions were excluded.

PF = sum of positive P&L / |sum of negative P&L|

TradingView excludes currently open positions from this metric. A zero-P&L trade adds to neither bucket. Avoid summing both entry and exit rows when the export repeats a trade result. TradingView: profit factor definition.

Interpretation on a consistent trade and cost basis
ResultWhat it establishes
PF < 1Losses exceed profits in the selected closed trades.
PF = 1Profits equal losses on the chosen cost basis.
PF > 1Profits exceed losses; the ratio does not measure return on capital.
PF = 0, losses > 0There are losses but no positive trade P&L.
No lossesNo finite ratio; inspect the sample instead of ranking infinity.

With no losing trades, division by zero gives no finite PF. Positive profits may be displayed as infinity; an empty or all-flat sample produces an undefined 0/0. A software placeholder of zero or a dash does not change that mathematical distinction.

Costs change both sides of the ratio

Consider five completed trades. Apply a hypothetical $20 total round-trip cost to each, with positions and fills otherwise held fixed. This is a cost-sensitivity example, not a broker fee quote.

Five trades before and after a $20 round-trip cost
TradeBefore costCostAfter cost
1+$600$20+$580
2+$300$20+$280
3+$100$20+$80
4-$200$20-$220
5-$300$20-$320
  • Before costs: gross profit = $1,000; gross loss = $500; PF = 2.00; total P&L = $500.
  • After costs: gross profit = $940; gross loss = $540; PF = 1.74; total P&L = $400.

Subtracting the full $100 from gross profit alone would give 900 / 500 = 1.80, which is wrong. Costs on losing trades increase the loss bucket. Costs can also change classification: a +$10 trade becomes -$10 after a $20 cost, so it moves into the loss bucket. Rebuild both totals from adjusted trade P&L.

In TradingView, commission settings apply to entries and exits; slippage is specified in ticks for market and stop orders. Set these assumptions before testing. Changing fill prices can also change later orders or position sizes, so rerunning the backtest is more complete than subtracting a flat amount afterward. TradingView: strategy properties. Verify which costs the export already includes before making further deductions.

Win rate alone does not determine profit factor

PF = (number of wins × average win) / (number of losses × average loss magnitude). If no trades finish flat, this becomes [win rate / (1 − win rate)] × [average win / average loss]. With flat trades, use the actual win and loss counts instead.

With 30 winners averaging $300 and 70 losers averaging $100, PF = 9,000 / 7,000 = 1.29. At the same 30% win rate and $100 average loss, a PF of 1.5 requires a $350 average winner: 30 × $350 / (70 × $100) = 1.5. The average realized payoff is different from the target-to-stop ratio set before entry.

For an amount per trade instead of a ratio, see the trading expectancy calculator. PF also omits initial capital, holding time and the sequence of returns. Reordering the same fixed P&Ls leaves PF unchanged while potentially changing drawdown.

A high PF can depend on one trade

Take a hypothetical ten-trade sample: winners of $900, $40, $30, $20 and $10, plus five losses of $100 each. Gross profit is $1,000, gross loss is $500 and PF is 2.00. The largest winner supplies 90% of gross profit. Excluding that trade as a sensitivity check gives $100 / $500 = 0.20.

This does not prove that the $900 winner was luck or should be discarded. Some strategies depend on rare large winners. It shows how much the conclusion depends on observing that kind of trade again. Report both the original result and the sensitivity result.

No magic trade count resolves this. Inspect the loss count, overlapping positions, different market conditions and results in periods withheld from parameter selection. Repeatedly tuning the strategy after inspecting a test period makes that period part of the selection process. TradingView discusses this problem in its overfitting guidance. For the broader sample question, read how many trades a backtest needs.

Reconcile TradingView profit factor with the trade list

  1. Record the symbol, timeframe, date range, currency, position sizing, commission and slippage assumptions for the run.
  2. Export the TradingView List of Trades. Use closed trades from the same all-trades, long-only or short-only selection as the summary.
  3. Count each closed trade result once. Check partial exits and repeated entry/exit rows before summing P&L.
  4. Compare the positive total, absolute negative total and closed-trade count. Resolve these differences before comparing rounded PF values.
  5. Check open P&L separately. Then review drawdown, cost sensitivity and the largest winner rather than accepting PF as a pass/fail score.

Pineify Backtest Deep Report calculates the ratio from imported closed-trade net P&L. It can help inspect that exported sample, but it does not rerun your strategy or add missing execution costs. A matched ratio verifies the aggregation, not the realism of the backtest. For testing workflow details, continue to profit factor in backtesting.

Profit factor FAQ

What is a good profit factor in trading?

There is no universal good threshold. Above 1 means the selected closed trades have a positive total P&L on the cost basis used. Whether 1.5 or 2 is useful evidence depends on costs, sample coverage, drawdown and performance on data not used to select the strategy. The ratio alone cannot establish future profitability.

What does a profit factor of 1.5 mean?

It means $1.50 of total winning-trade P&L for each $1 of total losing-trade P&L, measured as a positive magnitude. For example, $750 divided by $500 equals 1.5, with $250 total P&L. It does not mean a 50% return on account equity.

Can profit factor be above 1 while the same trades lose money?

No, if the trade set, currency and cost basis are identical and gross loss is positive. Total P&L equals gross profit minus gross loss, so PF above 1 implies a positive total. An apparent contradiction can come from omitted fees, open-position losses, different dates or a different trade selection.

What if there are no losing trades?

The denominator is zero, so there is no finite profit factor. With positive profits, software may display infinity or no value. With neither profits nor losses, the ratio is 0/0 and undefined. Neither case establishes how the strategy handles losses.

Does profit factor include commission and slippage?

It reflects whatever costs are included in the trade P&L being summed. Set commission and slippage assumptions before running the TradingView backtest, then check the exported P&L basis. Do not subtract costs twice. A report calculated from an export cannot recover execution costs that the source omitted.

How many trades make profit factor reliable?

No fixed count guarantees reliability. Check how many losses are in the denominator, how much profit comes from the largest winners, whether trades overlap, and which market conditions the sample covers. More trades from one repeated exposure do not provide the same evidence as independent observations across different conditions.

Can Pineify calculate profit factor from TradingView data?

Backtest Deep Report accepts TradingView List of Trades CSV data and calculates profit factor from imported closed-trade net P&L. Compare its trade count, gross profit and gross loss with the same TradingView run. It analyzes exported trades; it does not rerun the strategy or reconstruct missing fees and fills.

Inspect the trades behind the ratio

Use a TradingView List of Trades CSV in Backtest Deep Report to compare profit factor, gross profit, gross loss and trade count. Confirm your cost assumptions in TradingView first.

Open Backtest Deep Report

Review report features and access