Indicators & Strategy
TradingView Strategy Backtesting: Validate Your System with the Tester
Between "I feel this setup makes money" and "the data says this setup made money over five years" sits one honest backtest. TradingView's strategy tester lowers the barrier to a snippet of script.
From indicator to strategy
Swap indicator() for strategy() and add entry/exit orders:
//@version=6
strategy("EMA Cross Strategy", overlay = true,
initial_capital = 100000,
default_qty_type = strategy.percent_of_equity,
default_qty_value = 10)
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
Add it to the chart and the Strategy Tester at the bottom auto-generates a report, marking each entry and exit on the chart.
Read these four numbers first
- Max drawdown: look at it before net profit — drawdown decides whether you can hold the system long enough to reach profit;
- Payoff ratio × win rate: only their product is the expectancy; either alone will fool you;
- Number of trades: a backtest under 100 trades has essentially no statistical meaning;
- Commission and slippage: fill them in honestly in strategy properties — omitting them on an intraday strategy is self-deception.
Three signs of overfitting
- Nudge a parameter a little and performance changes a lot — you optimized noise;
- It only shines on one instrument / one period — switch both to check;
- More and more rules, each added to "fix" a few specific losses — that's memorizing the historical data.
Out-of-sample: tune on 2020–2024 data, validate on 2025-to-now. If performance collapses on the latter, start over. A backtest that skips this step is just a pretty curve.