VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Backtesting and validation

TradingView Strategy Tester: free backtests and what to check first

TradingView's free plan includes the Strategy Tester. Check four things before you trust a result: how many bars and trades the test covers, how orders fill inside each bar, whether commission and slippage are set, and whether the average trade is clearly larger than the round-trip cost.

By · Published · updated · Editorial policy

Contents
  1. Can you backtest for free on TradingView?
  2. How much history does a free Strategy Tester run actually cover?
  3. How does the Strategy Tester fill orders inside a bar?
  4. What does the bar magnifier change?
  5. How should you set commission and slippage?
  6. Which Strategy Tester report fields matter most?
  7. How do you research a chart idea on long history and bring it back to TradingView?
  8. Frequently asked questions
  9. References

Yes. TradingView's free plan includes the Strategy Tester, so you can run a Pine Script strategy on a chart at no cost. Before you trust it, check four things: how many bars and trades it tested, how orders fill inside each bar, whether commission and slippage are set, and whether the average trade clearly beats the round-trip cost.

Can you backtest for free on TradingView?

You can backtest for free on TradingView, because the Strategy Tester works on the free plan. The Strategy Tester is the panel below the chart that runs a strategy script over the bars loaded on that chart and reports trades, profit and drawdown. A strategy script is a Pine Script program that places simulated orders, unlike an indicator script, which only draws on the chart.

To run a test, add a strategy to a chart from your own scripts or from the public library. Then open the Strategy Tester panel and open the strategy's settings. The settings have two tabs that matter. Inputs holds the strategy's own parameters. Properties holds initial capital, order size, commission, slippage and the fill options. Most of the checks in this guide are in Properties.

The free plan and the paid plans run the same simulation logic. The main differences are how much history a chart loads and which extra options are available. Paid plans add options such as Deep Backtesting, which tests beyond the bars visible on the chart. TradingView changes plan details from time to time, so check its plan page for current limits.

How much history does a free Strategy Tester run actually cover?

A Strategy Tester run covers only the bars the chart has loaded. On short timeframes, that can be a few weeks. Your plan sets how many bars a chart loads. The number of days this covers depends on the timeframe and on how many hours the market trades. Work it out before you read the report.

Hypothetical example

Suppose your chart loads 5,000 bars. The market trades 20 hours a day, so it makes 240 five-minute bars a day. 5,000 ÷ 240 is about 21 trading days, roughly one month. On 60-minute bars, the same 5,000 bars cover 250 trading days, about one year. A strategy that trades twice a week would take only about 8 trades in the five-minute test. That is far too few to tell skill from luck.

To check what a report covers, look at the date of the first trade in the list of trades and compare it with today. Then count the closed trades. A common rule of thumb is to want at least a hundred trades before you read much into profit factor or win rate. Strategies with many parameters need more. If the period is short, use a higher timeframe or a longer history, or treat the result as a first sketch only.

How does the Strategy Tester fill orders inside a bar?

Without intrabar data, the Strategy Tester has to guess the order in which price moved inside each bar. That guess can make stop and limit results look cleaner than live trading. TradingView's broker emulator is the part of the tester that simulates fills. It sees only the open, high, low and close of each bar. TradingView's Pine Script documentation describes its rule. If the high is closer to the open than the low is, it assumes price went open → high → low → close. Otherwise it assumes open → low → high → close.

One hypothetical price bar with open 100, high 102, low 95 and close 97: the tester assumes the path open, high, low, close, so a target at 101.5 fills before a stop at 96, although the real path could have hit the stop first The assumed path decides One hypothetical bar, two exits 102 100 97 95 1 2 Target 101.5 Assumed path Stop 96 Real path may hit the stop first. So: rerun with the bar magnifier.
When a target and a stop both lie inside one bar, the assumed path inside that bar decides which one fills. The real path is unknown without lower-timeframe data.

This matters most when a stop and a target can both be hit inside the same bar. The assumed path decides the trade, but the real path may have been the reverse. Three more fill behaviours affect results:

  • Market orders fill at the next bar's open by default. A strategy that decides at a bar's close trades at the following open. That is realistic. The "On bar close" fill option instead fills at the close of the signal bar. For an intraday strategy, that close is a price you could rarely get after you have seen it.
  • Stop and limit orders fill at their own price unless the bar opens beyond it. Live stops in fast markets often fill worse.
  • Limit orders fill when price touches them. The "Verify price for limit orders" setting makes price trade a set number of ticks past your limit before it counts as filled. Live, a touch does not mean your order was filled.

What does the bar magnifier change?

The bar magnifier replaces the guessed path inside each bar with lower-timeframe data, so stop and target fills follow the order in which they really happened. In Properties, the "Fill orders" options include "Using bar magnifier", "On bar close" and "Using standard OHLC". With the magnifier on, an hourly bar is checked against smaller bars inside it, so the tester knows whether the stop or the target came first. Availability depends on your plan.

A quick test shows how much your strategy depends on the assumed path. Run it once with standard OHLC and once with the bar magnifier. Then compare net profit and the number of trades. A large gap means many trades hit a stop and a target inside the same bar, and those results rest on an assumption. Strategies with tight stops and targets close to entry are the most affected.

Two more checks help:

  • Look for repainting. Repainting is when a script shows signals on past bars that it would not have shown in real time. This often happens with higher-timeframe data or with calculations that update on every price tick. Watch the strategy run on a live chart for a few sessions. Then check that the signals stay where they first appeared.
  • Look at single trades. Open the list of trades and check a few entries on the chart against the rules.

How should you set commission and slippage?

Set commission and slippage before the first run, because both start at zero, and zero cost favours strategies that trade often. In Properties, commission can be a percent of the trade value, a cash amount per contract or a cash amount per order. Slippage is set in ticks per fill. For futures, use cash per contract and enter your broker commission plus exchange and clearing fees for one side. The tester charges it on entry and again on exit.

To turn ticks into money, look up the tick value of your contract. The futures contract calculator for tick size, tick value and trade profit shows it per contract. Exchanges can change contract specifications, so confirm them on the exchange's contract page. Then compare the cost with the report's average trade.

Hypothetical example

A report with no costs shows 300 trades and an average trade of $40. One tick is worth $12.50. Commission and fees are $4 per round trip, and slippage is set to one tick per fill, which is $25 per round trip. The round-trip cost is $29, so the average trade drops to $11. If live slippage turned out to be two ticks per fill, the average trade would be −$14.

Which Strategy Tester report fields matter most?

Read the report starting with the number of trades and the average trade, not net profit. Net profit depends on how long the test ran and how many contracts it traded. The average trade and the drawdown tell you more about whether the edge survives costs.

FieldWhat it tells youWhat to check
Total closed tradesHow much evidence the report containsEnough trades for the result to mean something; see the history section above
Average tradeNet result per trade after the costs you setClearly larger than the round-trip cost
Profit factorGross profit divided by gross lossRead it together with the trade count; a high value from a few trades means little
Max drawdownThe largest fall from an equity peakWhether you could sit through it at your real position size
Percent profitable and the ratio of average win to average lossHow often trades win and how big wins are against lossesUse both to work out the expectancy per trade and confirm it matches the average trade
Largest losing tradeThe worst single tradeWhether one trade erased weeks of gains
Commission paidTotal cost chargedNot zero; compare it with gross profit

One more check concerns your own process. Every time you change an input and run the test again, you are choosing among variants. The more variants you try, the more likely the best one looks good by chance (Bailey et al., 2014). Write down how many combinations you tried. Then judge the best one by how it does on a period you did not tune on.

How do you research a chart idea on long history and bring it back to TradingView?

A useful loop is to research and validate on long history, then bring the finished strategy back to TradingView for chart checks and alerts. A chart test answers "what did these rules do on these bars?" A research workflow also asks whether the rules hold on data they were not tuned on, and whether they still hold when costs and settings change.

A four-step loop: an idea seen on a TradingView chart is researched on years of data with costs, validated with walk-forward analysis, exported as Pine Script v6 and checked on the chart with the same settings, then the loop starts again with the next idea From chart to research and back One loop for each new idea 1 · Chart idea On TradingView 2 · Research Years, with costs 3 · Validate Walk-forward 4 · Export As Pine Script v6
The research loop: ideas start on the chart, are researched and validated on long history, and return to the chart as exported code.
  1. Write the idea as rules. Write the entry, exit, stop and the parameter ranges you want to test. Do not lock in the single setting that looked best on the chart.
  2. Research on long history with costs. Use years of your own historical bar data. Include commission, slippage and next-bar execution in every run.
  3. Validate. Use out-of-sample tests such as walk-forward analysis. Walk-forward analysis is a test that tunes the rules on one period, then checks them on the next period they never saw, and repeats this across the history. Also look at how results change across settings.
  4. Export and check. In AlphaPrime (Valynox), export the strategy as Pine Script v6; the steps are in how to export an AlphaPrime strategy to TradingView. Then add it to a TradingView chart.
  5. Match the settings. In Properties, use the same order size, commission, slippage and fill option, and use the same session on the chart.
  6. Compare trades over a period both tests cover. Check a sample of entries and exits. Small differences usually come from the data feed, the session settings or how contract rolls are handled. Find the cause before you trade the strategy.

In AlphaPrime, step 1 maps to strategy generation, step 2 to backtesting with fees, slippage and next-bar execution, and step 3 to strategy validation with walk-forward analysis and custom thresholds. Step 4 uses platform export to the supported trading platforms.

What this means if you use AlphaPrime: do the heavy research and validation in AlphaPrime on long history with costs included. Then export the strategy to TradingView and use the Strategy Tester to check fills, sessions and alerts on the chart with the same settings.

Frequently asked questions

Can you backtest for free on TradingView?

Yes. The Strategy Tester works on TradingView's free plan, and you can run any strategy script on a chart and read its report. The test covers only the bars the chart loads, and your plan sets that number. On short timeframes, this may be only a few weeks of data.

Does the TradingView Strategy Tester include commission by default?

No. Commission and slippage both start at zero. Set them in the strategy's Properties before the first run. For futures, use cash per contract for commission and enter slippage in ticks per fill.

What is the bar magnifier in TradingView?

The bar magnifier is a fill option that uses lower-timeframe data inside each chart bar to decide the order in which stops and limits were hit. Without it, the tester assumes a price path from the bar's open, high, low and close. Running a test with and without it shows how much a result depends on that assumption.

Why does my TradingView backtest differ from live trading?

Common causes are zero costs, limit orders that fill when price only touches them, the assumed price path inside a bar, and repainting signals. Set realistic commission and slippage and turn on "Verify price for limit orders". Then watch the strategy live for a few sessions to see whether its signals stay in place.

How many trades does a Strategy Tester report need?

There is no exact number. A common rule of thumb is at least a hundred closed trades, and more for strategies with many parameters. With a few dozen trades, profit factor and win rate can change a lot from just a few lucky or unlucky trades.

References

  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.

What AlphaPrime does here

AlphaPrime's strategy validation tests strategies on long history with walk-forward analysis and custom thresholds. Platform export sends the finished strategy's source code to the supported platforms, including TradingView as Pine Script v6.

See plans and pricing