Skip to main content
← Back to blog

Why Your Pine Strategy Loses Live When the Backtest Wins

📅 2026-10-17
✍️ Strategy Arena
TradingView Pine Script backtest overfitting live trading fees research

A Pine strategy that wins in backtest and loses live has almost always learned the past rather than a rule: its parameters were chosen on the very period it is judged on. The other common causes are fees and slippage missing from the backtest, look-ahead in the script, a market that changed regime, and execution assumptions that are too kind.

Updated 17 October 2026. Research on past data, not investment advice.

The five causes, from most common to most subtle

Cause What happens How to spot it before going live
Tuning on the past (overfitting) Parameters fit the noise of the history A period set aside before any tuning
Fees and slippage Every round trip costs; the backtest ignores it Real fees + a stress at 2 or 3 times fees
Look-ahead The script uses data not yet known lookahead_off, no warning banner
Regime change A trend rule meets a decline or a range Test across several cycles (walk-forward)
Execution assumptions Fills at the close, no gaps inside a bar Check process_orders_on_close, stop orders

1. The backtest learned the past

This is the main cause. Try 10/40, 15/60, 20/50 and keep the best, and the best score mechanically drifts away from the true expectation. The more you try, the further it drifts.

Two Lab measurements:

  • Turtle 20/10 on EUR/USD: +31.9% on the training period, −42.1% over 2013-2026 (1,306 variants judged).
  • GPU genetic search: a champion at +172.7% on its training data, −37% on unseen data (post-mortem).

On pure noise, with no signal to find, an automatic research loop "improves" in 88 to 98% of sessions (350 autoresearch sessions). A backtest that improves with every attempt proves nothing. Detection method: overfitting in a TradingView strategy.

2. Fees and slippage were missing

In Pine, slippage is declared in ticks and is 0 by default (TradingView documentation). If the script declares no commission, check what the Properties tab applies.

Order of magnitude, by simple arithmetic: a fully invested strategy making 258 round trips at 0.10% per side keeps 0.998^258 ≈ 0.60 of its capital from fees alone, so about 40% gone in commissions before any market gain or loss. On a short signal the gross edge vanishes: our best "RSI below 30" case went from +0.027% to −0.173% after a 0.20% round trip (study). Details: fees and slippage in the Strategy Tester.

3. The script read the future

The classic case: request.security on a higher timeframe with lookahead_on. In backtest, the daily bar "knows" its close in the morning; live, it does not. TradingView's documentation also notes that some execution settings can cause repainting, and calls it misleading to know a bar's high at its open. If the report shows a warning banner, read it.

4. The market changed regime

A trend rule lives on trends. In our walk-forward test of five famous trend-following strategies over 2019-2025, all of them protected in the fold containing the 2022 decline, and all five lost the last fold to buy-and-hold (for example Faber −50.2% vs +99.7%) (results). A strategy tuned on 2022 and launched in 2023 changes worlds.

5. Execution was too good

TradingView's emulator assumes a price path inside each bar (open, high, low, close, or the reverse) and no gaps within a bar. A tight stop, a target a few ticks away, an order filled "on close": all places where live trading differs. Limit orders fill at the requested price or better: live, they may not fill at all.

The test to run before risking money

  1. Set a period aside before any tuning, and open it only once.
  2. Declare real fees, then recompute at 2 and 3 times those fees.
  3. Check lookahead_off and the absence of warnings in the report.
  4. Test across several cycles or several markets.
  5. Compare with buy-and-hold over the same window.

  6. Test your Pine strategy for free: the Quick Check compares the script with buy-and-hold, fees included.

  7. The free Lab for Windows: sealed period, fee stress, counted trials, local verdict.
  8. Check the trades in TradingView: replay the Pine export and compare trade by trade. Open TradingView (partner link).

FAQ

Is my TradingView backtest wrong?

Rarely in its calculation: our exports replayed in TradingView gave the same trades as our engine to the cent (trade-by-trade check). It is the assumptions (tuning, fees, look-ahead) that make it misleading.

Is paper trading enough to validate a strategy?

It tests execution on new data, which is useful, but over a short period. It complements a held-out test period; it does not replace it.

How long should I test before going live?

Long enough to gather independent events: the Lab's judge asks for at least 30 in the test period.

Can a strategy that loses live be fixed?

Changing parameters after the failure is a new trial, tuned on data you have now seen. It needs a new unseen period to be judged.

Sources

Disclosure: Strategy Arena takes part in the TradingView partner program. If you create a new account through our links and then subscribe on the web, we may earn a commission at no extra cost to you. It changes no number and no verdict in this article.

Research on past data, not investment advice. Past results do not guarantee future results.

⚠️ Disclaimer — This article is for informational and educational purposes only. It does not constitute investment advice or a buy/sell recommendation. Past performance does not guarantee future results. Strategy Arena is an educational simulator with virtual capital. Always do your own research before making investment decisions.

Enjoyed this article? Share it

𝕏 Share on X ✈️ Telegram

Turn a local result into durable proof

The Lab runs free on your PC. Paid options only keep or expand the work — they never change the verdict.

Get the Lab (free) Builder / Operator Publish a Lab Report Lab Reports Hall
TradingView Starter
Choose the account path. Prove the strategy separately.
Your first chart and price alert do not require the Lab. Strategy Arena proof remains required before trusting or exporting a strategy.
Partner attribution is for first-time users and web purchases only. Strategy Arena may earn a commission on eligible purchases; starting with a free account needs no payment.
I have never had an account · Start free I already have an account Check a strategy
More TradingView paths
Evidence-gated Pine review