TradingView Backtester: test a strategy before it costs you money.
Every strategy that blows up a live account once had a beautiful backtest. The difference between a test you can trust and a fantasy is a handful of settings and traps most traders skip. Here is how the TradingView Strategy Tester actually works, how to make it honest, and what to do the day your strategy survives it.
FIRST THINGS FIRST
Strategy vs indicator: only one of them backtests.
TradingView runs two kinds of Pine Script. An indicator draws lines, labels and alerts - it never simulates a trade, so there is nothing to backtest. A strategy declares itself with strategy() instead of indicator() and places simulated orders with strategy.entry and strategy.exit. Only strategies produce results.
To run the test: open your symbol and timeframe, add the strategy from the Pine Editor (or the community library), then open the Strategy Tester tab at the bottom of the chart. You get the equity curve, net profit, profit factor, max drawdown and the full trade list. If you wrote the rules as an indicator, you are not stuck - the entries and exits translate into a strategy almost line for line, or you can go straight to alerts and validate in real time instead (more on that at the end).
REALISM
Make the test honest: commission, slippage, data.
A backtest with zero costs is marketing, not research. In the strategy settings set a commission that matches your broker (a per-lot figure for forex, or a percentage for crypto) and a few ticks of slippage on every fill. These two fields alone routinely turn a 60%-win-rate wonder into breakeven - better to learn that now than from your broker statement.
Two more honest-makers. The bar magnifier (paid plans) uses lower-timeframe data to guess what happened inside each bar, so stops and targets within one candle resolve in the right order - without it, TradingView assumes a path that may flatter your strategy. And deep backtesting on higher paid plans unlocks the full symbol history instead of a capped bar window, which matters because a strategy tested only on the last trending year has not really been tested. Free plan limits change, so check TradingView's current plan page for exact bar caps.
THE SILENT KILLER
Repainting: the backtest that reads the future.
The most dangerous backtest bug is not in your logic - it is in your timing. A script repaints when its historical signals were computed with information that was not available at that bar. The equity curve looks supernatural because, in a sense, it was.
request.security with lookahead
Pulling a higher timeframe with request.security(..., lookahead=barmerge.lookahead_on) imports the higher bar's close before it finished. Classic future leak.
Signals inside the live bar
Entries that fire on the still-forming bar (intrabar calculations, calc_on_every_tick) cannot be reproduced bar-close by bar-close. The tester may assume you filled at a price the market only touched for a second.
Curve-fitted parameters
Not repainting, but the same outcome: optimize the inputs until the past looks perfect and you have fitted noise. The tell is razor-thin stability - change the length from 21 to 23 and the edge evaporates.
FIX → keep an out-of-sample date range the optimization never touches, and demand the strategy survive it.THE STEP EVERYONE SKIPS
Survived the backtest? Forward-test it on MT5 demo.
A backtest, even an honest one, is still a simulation on historical candles. It cannot show you live spread widening at the news, the half-second between your alert and the fill, or how your strategy behaves when three signals fire in the same hour. The cheapest reality check is a forward test on an MT5 demo account: same rules, live market, fake money, real fills.
The practical way is to convert your strategy rules into TradingView alerts - one message per entry and exit - and let them execute automatically on the demo. That is exactly what SignalForge does: it routes your TradingView webhook alerts to MetaTrader 5 in milliseconds, with stop-loss, take-profit, multi-TP, break-even and trailing handled by the EA. You can start with the 14-day free trial, no card required, and watch a full cycle of signals fill on demo before a single real dollar is at risk. If you are choosing between bridges, our honest TradingView to MT5 bridge comparison lays out the options.
Treat the forward test as part of the strategy, not a formality: two to four weeks on demo, compare live fills against the backtest's assumptions, and only then decide. If you want the alert JSON right the first time, our guide on Pine Script alert webhooks covers the message format, and copying TradingView signals to MT5 walks the full pipeline end to end.
FAQ
Quick questions.
Email [email protected] if yours isn’t here.
Is the TradingView backtester free?
+
What is the difference between an indicator and a strategy on TradingView?
+
Why does my TradingView backtest look amazing but lose live?
+
How much history can I backtest on TradingView?
+
What should I do after a good TradingView backtest?
+
Benjamin SF is the founder of SignalForge and an expert in trading algorithm automation. He builds and operates the SignalForge bridge and the SFCloud hosted-MT5 fleet for prop-firm traders.
Forward-test your strategy on MT5
SignalForge routes your alerts to MetaTrader 5 in milliseconds. 14-day free trial, no card required.
SignalForge AI is an order-execution tool. We do not provide investment advice. Trading involves risk of loss.