Black Friday: 2 years for the price of 1.Or 3 months for the price of 1. On Pro.2 d 5 hleftSee plans →
Free tool

Free out-of-sample test for Pine Script

Paste a strategy and press Run. We backtest it with costs, then judge the last third of the history on its own. Tune your settings on the first two thirds only, and the last third tests them.

Free plan · unlimited backtests · no card
One opening range script, 24 versionsMNQ and MES · 5-minute candles · costs charged
First 16 months · to 24 February 202623 of 24 made money
The 8 months after · to 22 October 20261 of 24 made money

Each square is one version: a 5, 15 or 30-minute range and a 1R to 3R target. A version keeps its place in both rows, so a green square over a red one made money first and lost it after.

From 23 October 2024 to 22 October 2026. Every version and trade

Paste your script

Pine v6, as TradingView has it.

One opening range script, 24 versionsMNQ and MES · 5-minute candles · costs charged
First 16 months · to 24 February 202623 of 24 made money
The 8 months after · to 22 October 20261 of 24 made money

Each square is one version: a 5, 15 or 30-minute range and a 1R to 3R target. A version keeps its place in both rows, so a green square over a red one made money first and lost it after.

From 23 October 2024 to 22 October 2026. Every version and trade

Paste the script above and press Run. The tester fits nothing to the last third of the history; it reports that stretch on its own, with costs, and says whether the result survived. TradingView leaves this split to you.

Why it matters: tuned on TSLA from 2016 to 2023, the highest-scoring of 16 SuperTrend settings made 1,606.4%. On the next three years it lost 13.4% while the stock rose 51.8%.

On futures: one opening range script, run 24 ways on MNQ and MES, made money in 23 versions over the first 16 months. Over the 8 months after, 1 did. The opening range study

How the split works

Every run is split by date. About the last third of the bars is the out-of-sample part and the two thirds before it are the in-sample part; the report shows each with its dates. Both pay the same costs: 0.05% commission and 0.025% slippage on each side of every trade by default, or the commission your script declares. A rule that fires on a close fills at the next bar's open.

The last third gets one of four words:

  • Too few trades to judge: fewer than 5 trades in it.
  • Did not survive: a Sharpe ratio of zero or below in it.
  • Decayed: a Sharpe ratio above zero but under half of the earlier part's.
  • Survived: a Sharpe ratio above zero and at least half of the earlier part's.

It is a fair test only if the settings were chosen without looking at that last third: tune on the earlier part, then run once. And it is one stretch of one symbol, a description of the past, not a forecast.

Walk-forward testing

One split is one draw. Walk-forward testing repeats it: fit the settings on the history up to a point, test them on the stretch right after, then move the point forward and fit again. In Alpha Charts it runs in the Optimiser, on three stretches. On the Free plan the Optimiser's check says in words how your settings did on the stretches after the ones they were tuned on; Pro shows each stretch with the settings it chose and applies them in one press.

On TSLA, the same SuperTrend strategy fitted this way made money and beat its starting settings on two of the three stretches: the worked example, step by step.

What the research says

Bailey, Borwein, López de Prado and Zhu (2014) show that trying a fairly small number of settings is enough to make a backtest look impressive, that the more settings are tried the likelier the result is overfit, and that an overfit backtest can lose money on the data that comes after. “Pseudo-Mathematics and Financial Charlatanism”, Notices of the AMS 61

Run the test on your script

Paste it in the box at the top: the split, the costs and the verdict come with every run.

Free account

No card, no time limit.

$0
  • Unlimited backtests, costs charged, with the out-of-sample check
  • The Pine script audit and the full trade list
  • The Pine Copilot writes and edits your script
  • 50 AI credits a day
The Alpha Charts terminal a free account opens: the Pine Copilot beside the chart

Prop Ready opens all two years of futures minute bars on a computer for $39 paid once and has 7 days money back. Pro adds the optimiser and every AI tool and has 30 days money back. See the plans

Questions

What is out-of-sample testing in Pine Script?

Choosing a strategy's settings on one stretch of history and judging them, unchanged, on a later stretch that played no part in choosing them. In TradingView you do it by hand: tune on the earlier dates, then run the later dates once. This tester splits every run for you: about the last third of the history is reported on its own, with costs charged and its dates shown.

Does TradingView have an out-of-sample test?

Not as a built-in split. TradingView's Pine Script manual describes splitting the data into in-sample and out-of-sample parts as something traders do themselves: optimise on the first part, then test on the later one. The Strategy Tester reports the testing period you choose. (TradingView's "Strategies" page, read 16 November 2026.)

How much data should be out-of-sample?

There is no fixed rule. This tester keeps about the last third apart by default and wants at least 5 trades there before it gives a verdict; with fewer it says too few trades to judge. Whatever split you use, choose it before you look at the results: moving it afterwards turns the test back into tuning.

Is this out-of-sample test free?

Yes. Run opens your script in the Alpha Charts terminal on the Free plan: a free account, no card, unlimited backtests with costs charged and the last third judged on every run. Prop Ready adds two years of futures minute bars, the screener and 100 AI builds every 30 days for $39 paid once and has 7 days money back. Pro at $99.99 a month adds the Optimiser's settings for every walk-forward stretch and has 30 days money back.

What is walk-forward testing?

The out-of-sample test repeated through time: fit the settings on the history up to a point, test them on the stretch right after, then move the point forward and fit again. The Optimiser runs it on three stretches, and its verdict says on how many of them the fitted settings made money and did better than the starting ones.

More on testing a strategy

Out-of-sample and walk-forward testing in TradingView, by hand and with the TSLA example in full. The free Pine Script backtester runs the same test on every script. How fills, costs and the verdicts work: Data and methodology.

The numbers are the tester's own runs: TSLA on daily bars from 4 January 2016 to 19 October 2026, the opening range script on 5-minute futures bars from 23 October 2024 to 22 October 2026. TradingView's Pine Script manual read on 16 November 2026. A backtest describes the past; it is not a forecast or advice. TradingView and Pine Script belong to TradingView, Inc.; Alpha Charts is not affiliated with it. Updated 28 November 2026.

Free out-of-sample testFree account, no cardPaste your script