Backtesting guide
Maximum adverse excursion and MFE in TradingView backtests
Maximum adverse excursion (MAE) is the largest unrealized loss from a trade's entry while it remains open. Maximum favorable excursion (MFE) is its largest unrealized profit. Neither is the final realized P&L. Use both to examine trade paths and propose exit rules, then rerun the strategy to test those rules.
Read the practical guideKey Takeaways
- MAE and MFE describe each trade relative to its entry; maximum account drawdown measures the account against an equity peak.
- Currency, percentage of entry value, and multiples of initial risk answer different questions. Label the denominator before comparing trades.
- An excursion pair records extremes, not their order. It cannot establish whether a stop or target would have filled first.
- A trade-list CSV needs valid excursion fields. Entry, exit, and realized P&L alone cannot recover the missing intratrade highs and lows.
Calculate MAE and MFE for long and short trades
For a fixed-size linear position, let E be entry price, L the lowest price while the position is open, H the highest, and X the exit price. Include the entry in the observed interval. Express excursions below as nonnegative loss or gain magnitudes. These formulas assume one entry, one exit, no scaling, and no costs.
| Measure in price units | Long | Short |
|---|---|---|
| MAE | max(0, E - L) | max(0, H - E) |
| MFE | max(0, H - E) | max(0, E - L) |
| Realized price change | X - E | E - X |
- Use only prices observed while the trade was open. A bar high after an intrabar exit is not part of that trade.
- TradingView uses a broker emulator. Historical bar assumptions and available intrabar data affect simulated fills and the price interval belonging to a trade.
- Multiple entries, partial exits, changing exposure, inverse contracts, and currency conversion require position-aware calculations. Do not apply the simple fixed-size formula to an aggregated trade without reconciling it.
Follow two hypothetical trade paths
Assume 10 shares, a $100 entry, a $1 value per one-point move per share, and no fees or slippage. The long starts with a planned stop at $96; the short starts with a planned stop at $104. Initial risk is $40 for either trade. The sequences below are observed prices in chronological order, ending at the exit.
| Trade | Price path | MAE | MFE | Realized P&L |
|---|---|---|---|---|
| Long | 100 → 98 → 106 → 103 exit | $20 | $60 | +$30 |
| Short | 100 → 103 → 94 → 97 exit | $30 | $60 | +$30 |
- Long: the lowest open price is $98, so MAE = (100 - 98) × 10 = $20. The $106 high gives MFE = $60. Selling at $103 realizes $30.
- Short: the $103 high is adverse, so MAE = (103 - 100) × 10 = $30. The $94 low gives MFE = (100 - 94) × 10 = $60. Covering at $97 realizes $30.
- Both trades realize half their MFE: $30 / $60 = 50%. This exit-capture ratio is one definition of trade efficiency, not a universal execution score. Costs and the choice of gross or net P&L change its interpretation.
Convert currency, percent, and R without mixing denominators
For these examples, currency excursion equals price excursion × quantity × point value. Entry notional is $100 × 10 = $1,000. Percentage excursion is 100 × currency excursion / entry notional. An R multiple divides by the positive initial monetary risk fixed before entry, here $40. R is not recalculated using the largest loss observed afterward.
| Trade and measure | Currency | % of entry notional | Initial-risk multiple |
|---|---|---|---|
| Long MAE | $20 | 2% | 0.50R |
| Long MFE | $60 | 6% | 1.50R |
| Short MAE | $30 | 3% | 0.75R |
| Short MFE | $60 | 6% | 1.50R |
| Either realized P&L | +$30 | +3% | +0.75R |
- TradingView describes trade excursion percentages relative to trade size. Do not substitute starting account equity, margin posted, or a different currency without labeling the change.
- An entry notional of zero makes this percentage undefined. Missing or zero initial risk makes R undefined; a missing planned stop cannot be reconstructed from realized P&L.
- A trade that never moves against entry has zero gross MAE. A trade with zero MFE has no defined realized-P&L-to-MFE ratio. Fees can still make its net result negative.
- When trade sizes differ, currency scatter plots combine size and price movement. Percentage or R normalization can help, but only when the denominator exists and is comparable.
Read scatter plots as stop candidates, not tested stop rules
A conventional MAE-versus-realized-P&L plot puts adverse excursion on the horizontal axis and the final outcome on the vertical axis. Backtest Deep Report instead plots MAE horizontally and MFE vertically in currency, groups points by realized outcome, and shows P&L in each point's tooltip. A point above its MFE = MAE diagonal only means favorable excursion exceeded adverse excursion; it can still represent a losing trade.
| Hypothetical point | MAE: x | MFE: y | Final P&L | Read the point |
|---|---|---|---|---|
| A | 0.50R | 1.50R | +0.75R | Small adverse move, profitable exit |
| B | 0.75R | 2.00R | +1.00R | Winner that exceeded 0.50R MAE |
| C | 1.50R | 2.00R | -1.00R | Above the diagonal, yet closed at a loss |
| D | 2.00R | 0.25R | -1.50R | Large adverse move with little favorable excursion |
- These R coordinates explain the geometry; the current product chart uses currency. A and B lie left of a proposed 1R stop boundary, while C and D lie right of it. That makes 1R a candidate to investigate, not an optimal threshold.
- Count both winners and losers beyond a candidate boundary, inspect sample size, and separate long and short trades where their behavior differs. Four illustrative trades establish no statistical threshold.
- Re-run the strategy with the candidate stop and realistic costs, then evaluate a held-out period. Earlier exits can change later entries, position sizing, and exposure, so editing old P&L values is not an equivalent backtest.
Why excursions cannot tell you which exit came first
Consider two long price paths with entry $100 and exit $102: path A is 100 → 97 → 106 → 102; path B is 100 → 106 → 97 → 102. Both have MAE of 3 points, MFE of 6 points, and realized profit of 2 points. They occupy the same scatter coordinates despite different event order.
- With a proposed stop at $98 and target at $105, path A crosses the stop first and path B crosses the target first. This comparison assumes continuous price movement and exact fills; gaps and slippage can change execution.
- Even an export containing both extrema loses their timestamps and intervening prices. It cannot fully simulate trailing stops, breakeven rules, or simultaneous stop/target touches.
- TradingView Bar Magnifier can use lower-timeframe data to refine historical fill simulation where coverage exists. It does not turn an exported pair of excursion numbers into a complete tick path.
Check TradingView CSV fields before trusting the chart
Use the List of trades export and retain the original file. In the current Backtest Deep Report importer, inspect the exit row for each trade: its monetary excursion fields supply the plotted values. The importer accepts Favorable excursion, MFE, or Run-up for MFE, and Adverse excursion, MAE, or Drawdown for MAE, including supported currency suffixes.
- If TradingView downloads an XLSX workbook, save the trade-list sheet as CSV before importing. Preserve headers, timestamps, signs, and separate currency and percentage columns; a workbook itself is not the CSV input described here.
- Check Trade #, Type, timestamps, direction, quantity, entry and exit prices, net P&L, and both excursion amounts against a few trades in TradingView. Confirm trade counts and that open positions are handled consistently.
- Keep currency amounts separate from percentage columns. The importer uses prefix matching, so a percentage column placed before its matching amount column can be mistaken for that amount. Confirm chart values against the original export, especially after rearranging headers.
- The importer converts excursion amounts to absolute values. A source MAE of -20 therefore plots at +20. Missing or blank excursion values currently fall back to zero; zero on the chart does not prove the trade had no excursion.
- For the fixed-size, no-cost examples, realized P&L must lie between -MAE and MFE. Net costs, scaling, or inconsistent units can break that simple check and need reconciliation.
- The importer pairs the first entry and first exit for a trade ID. Review partial exits and multi-entry records separately. It does not fetch market data to reconstruct missing extrema, nor does it preserve an intratrade price sequence.
Keep trade excursion separate from maximum account drawdown
MAE resets its reference to each trade's entry. Account drawdown compares equity with a prior account peak and can span several trades. For example, an account peak of $10,000 followed by a closed loss of $300 and then a $200 adverse move in the next position gives a $500 decline from that peak, while the second trade's MAE is only $200. This simplified example assumes no overlapping positions, costs, or cash flows.
Direct Pineify workflow
Inspect the excursions in your TradingView export
Import a compatible TradingView trade-list CSV into Backtest Deep Report to view its MAE-versus-MFE currency scatter chart and inspect the realized P&L of individual trades. Reconcile the source fields before drawing conclusions from the distribution.
Review supported excursion fields and scatter points alongside your original export.
Review trade excursionsBoundary: The report analyzes the supplied trade records. It cannot recover missing intratrade prices or prove how a different stop would have performed. Percentage and R examples on this page are independent calculations, not chart unit options.
Primary sources
- TradingView: List of trades favorable excursionVerified 2026-10-17
- TradingView: List of trades adverse excursionVerified 2026-10-17
- TradingView: Strategies, broker emulator and Bar MagnifierVerified 2026-10-17
- TradingView: Maximum account drawdown calculationVerified 2026-10-17
This page is educational and does not provide investment advice. Backtests are hypothetical, depend on their data and assumptions, and do not guarantee future results. Trading can result in substantial loss.