GUIDE · QUANT

Backtest

The Backtest runs your script — the actual Pine, not a re-implementation of it — across our bars, and reports what it would have done after costs. It is built to disappoint you honestly rather than flatter you: fills are pessimistic, costs are charged on both sides, and a third of the history is kept out of the fit.

The fill rules

Every assumption here is deliberately the unkind one. A backtest that assumes it can fill at the price that triggered it is describing a market that does not exist.

RuleWhat it doesWhy it is the unkind choice
FillsThe next bar's openYou cannot trade a bar you have not finished watching.
SignalsConfirmed bars onlyNothing intrabar, and nothing that can repaint into a better entry.
Costs5 bps commission, 2.5 bps slippage, per sideCharged on the entry AND the exit, including the final open trade when the history runs out.
BenchmarkBuy-and-hold, same entry costA cost-free benchmark makes every script look better than it is.
Sizing100% of equity, one positionNo leverage and no pyramiding, so the curve is the signal rather than the sizing.
Commission and slippage are editable, and setting them to zero is the fastest way to make a bad script look good. The defaults are there because they are roughly what a liquid US equity actually costs.

Reading the strip

Six numbers sit above the equity curve. Net return is the least interesting of them.

NumberWhat it isHow to read it
Net returnAfter costs, dollars beneathOn its own it says almost nothing — a long-only script in a bull market makes money by accident.
vs buy & holdThe same money, left aloneThe number that matters. A +80% that trails a +392% buy-and-hold is a losing script.
Max drawdownPeak to troughDecides whether you could actually have held it. Most people cannot hold what they backtest.
Win rateWins over tradesA high rate with poor returns means the losers are large.
Profit factorGross win ÷ gross lossBelow 1 the script loses money by construction, whatever the win rate says.
SharpeReturn per unit of volatilityAnnualised, with the average holding period beside it.

Held out

The tester keeps two periods and writes both out with their start, end and length: in sample, the part you tune on, and out of sample, the part no tuning touched. Out of sample is the last stretch of the period: the setup offers the lengths the period allows (3M, 6M, 1Y and 2Y on three years of daily bars, each leaving at least 30 bars on both sides), the one nearest a third is the default, or you start it at any date. Wherever the result appears the two periods are marked: a bar over each on the chart with the out-of-sample bars shaded, the same shade on the equity curve, and one line per period in the results with its dates, length, bars, trades, net and Sharpe. The out-of-sample line ends in one word: survived, decayed, or did not survive. A result that works in sample and dies out of sample is the single most common way a strategy lies to you, and it is worth more than every other number on the page.

When to believe it

Twenty trades a year is the floor for drawing any conclusion at all. Under that the page says so in place of a verdict, because with eighteen trades over three years the numbers are noise wearing a suit. One symbol and one price history is a reason to test a script elsewhere, not evidence of an edge — and the universe is today's index members, so names that dropped out are missing and the sample flatters.

When the numbers do hold up, the Optimiser is the next question: whether the settings did anything, or whether the best of many tries just got lucky.