📊 Tutorial Cluster

Backtesting on TradingView — Test Strategy Properly

By Dan Machado · 9 min read

Before deploying any strategy with real money — even on demo — you must backtest. Backtesting answers the only question that matters: “would this strategy have made money historically?” TradingView’s Strategy Tester is free and built-in. This guide shows how to use it properly, avoiding the common pitfalls that produce misleading results.

🎯 Quick Reality Check

Backtesting answers a probabilistic question, not a deterministic one. A profitable backtest doesn’t guarantee profit. But an unprofitable backtest does guarantee live losses if you deploy unchanged. Backtest filters bad strategies out — that’s the actual value.

Indicator vs Strategy Script

This is critical:

  • Indicator = visual only, no trade execution. Uses indicator() in Pine Script.
  • Strategy = places simulated trades, calculates P/L. Uses strategy().

Only strategy scripts can backtest. If you have an indicator, convert it first. Quick prompt for ChatGPT/Claude: “Convert this Pine Script indicator into a strategy script with 2% position sizing, 1% stop-loss, 2% take-profit. Initial capital $1000.”

Step-by-Step: Run Your First Backtest

  1. Open TradingView chart on your asset (e.g. EURUSD H1, V75 if available)
  2. Pine Editor (bottom tab) → paste strategy code → Save
  3. Click “Add to chart”
  4. Click “Strategy Tester” tab (bottom panel)
  5. Wait for backtest to compute (5-30 seconds)
  6. Review the 5 tabs: Overview, Performance Summary, List of Trades, Properties, Settings

The 5 Numbers That Matter

MetricHealthy RangeWhat It Means
Profit Factor> 1.5$1.50+ won per $1 lost. Below 1.5 = no real edge
Max Drawdown< 25%Worst peak-to-trough. Anything > 30% = unusable
Win Rate> 50%Not most important. PF matters more
Net ProfitPositive after feesTotal $ won. Must be net of commission
Sharpe Ratio> 1.0Risk-adjusted return. Higher = smoother equity curve

⚠️ Win Rate Is Misleading

A 70% win rate strategy can lose money. A 35% win rate strategy can be hugely profitable. Profit Factor (PF) is the real number — it accounts for wins, losses, and their sizes together.

The Biggest Trap: Overfitting

Overfitting = tuning strategy parameters until backtest looks beautiful, but it only works on that historical period. Deploy live → it fails immediately.

🚫 Overfitting Red Flags

1. Strategy uses 8+ tunable parameters
2. Tiny parameter changes massively change results
3. Optimised to 95% win rate on backtest
4. Tested on only one symbol, one timeframe
5. Backtest period < 6 months
6. “Cherry-picked” date range that includes only favourable conditions
Any of these = your strategy is fitted to history, not predicting future.

How to Avoid Overfitting

1. Use Walk-Forward Testing

  • Split history into “in-sample” (optimise here) and “out-of-sample” (validate here)
  • Example: optimise on Jan-Jun 2025, validate on Jul-Dec 2025
  • If out-of-sample also profitable, strategy has real edge
  • If only in-sample works, you’ve overfitted

2. Test Multiple Symbols

  • Same strategy on EUR/USD, GBP/USD, USD/JPY, V75
  • If profitable on 3+ of 4, robust
  • If only 1 works, suspicious

3. Test Multiple Timeframes

  • Test M5, M15, H1, H4 with same parameters
  • Should be consistently profitable or unprofitable
  • Erratic results = noise, not edge

4. Keep Parameters Simple

  • Strategy with 3 parameters = robust
  • Strategy with 10+ parameters = almost certainly overfitted
  • Each new parameter has to dramatically improve PF to justify

TradingView Strategy Tester Settings

In Properties tab (within strategy() function call or Settings panel):

  • Initial capital: $1000 (or whatever matches your real account)
  • Currency: USD
  • Order size: “% of equity” set to 2%
  • Pyramiding: 1 (no stacking)
  • Commission: 0.05% per trade
  • Slippage: 1 tick
  • Process orders on close: true (more realistic)

Without realistic commission and slippage, backtests are optimistic by 20-40%.

Reading Equity Curve

The visual equity curve tells more than numbers:

  • Steady upward slope = healthy
  • One big jump then flat = lucky single trade, not edge
  • Sawtooth pattern = strategy works in some conditions, fails in others
  • Sharp drops = drawdown risk you might not survive emotionally
  • Recent decline = strategy may be losing edge as market evolves

Demo After Backtest, Not Instead

🛑 Most Common Mistake

“Backtest shows 80% win rate, I’m going live!” No. Demo for 30 days minimum after backtest. Why:
• Backtest data may differ from real-time data (rare but happens)
• Slippage on live can be worse than modelled
• Market regime may have changed since backtest period
• Psychology of watching real trades execute is different
30-day demo confirms strategy works in current conditions, not just historical.

SA-Specific Considerations

  • USD/ZAR: backtest at least 1 year to catch SARB rate cycles
  • JSE stocks: include load shedding period (post-2022) for realism
  • V75: synthetic, less affected by SA events — easier to backtest
  • Trading hours: SAST = GMT+2; verify backtest timezone matches

Free TradingView vs Pro for Backtesting

✓ Free Tier Is Enough

Strategy Tester is fully unlocked on free tier. The only limits relevant to backtesting:
• 1 saved chart (workaround: save Pine Script locally as .pine file)
• 1 active alert (irrelevant for backtesting)
• 3 indicators per chart (combine into 1 via Pine if needed)
Pro plan ($14/mo ~R260) helps with active monitoring, not backtesting.

Sample Backtest Workflow

  1. Have an idea: “RSI mean reversion on V75”
  2. Generate strategy script via AI (see 5 AI Prompts)
  3. Run on TradingView Strategy Tester, last 6 months
  4. Check: PF > 1.5? Max DD < 25%? Net positive?
  5. If yes: walk-forward test (3 months out-of-sample)
  6. If still yes: test on 2 other symbols
  7. If all 3 robust: demo 30 days on Deriv
  8. If demo also profitable: small live deposit (R200-R500)

Most strategies die at step 4 or 5. That’s the point — backtesting filters out the 90% of bad ideas before they reach your real money.

🚀 Backtest first, then demo on Deriv (FSCA, $10,000 virtual):

Open Free Demo Account

Related Reading

DM

Dan Machado

Founder IA Trader Pro · Backtested 200+ strategies

⚠️ Disclaimer: Past performance does NOT guarantee future results. Backtesting filters bad strategies but doesn’t predict the future. Deriv is FSCA-authorised (FSP 50885). Contains affiliate links. Full disclaimer.