Data and methodology
What a backtest here is made of: the prices and how they are adjusted, the list of stocks and what it leaves out, how a trade fills and what it costs, how the result is judged, and how to check it somewhere else. Where the engine does not do something, this page says so.
The data
| What | Where it comes from | Detail |
|---|---|---|
| History | Alpaca, the consolidated US tape | Every US exchange's trades, regular session 09:30 to 16:00 New York by default; the extended day 04:00 to 20:00 on request. |
| Live prices | IEX, through Alpaca | The newest 15 minutes of a session come from IEX alone, so their volume is IEX's share; everything older is the full tape. |
| Daily bars | From 2016 | About ten years of sessions for any US-listed stock or ETF. |
| One-minute bars | The last 120 sessions | About six months. |
| Five-minute bars | The last 600 sessions | About two and a half years; hourly and longer intraday bars are folded from them. |
| Adjustment | Splits only | Prices are split-adjusted. Dividends are not folded in, so every result is a price return, not a total return. |
| Missing bars | None invented | A run uses the bars the tape has. A session the provider is missing is simply absent; no bar is interpolated. |
A finished month of bars is cached once and re-read only when a split has changed the adjusted prices, so two runs of the same script on the same range see the same bars.
The universe, and the bias it carries
The tester runs any US-listed stock or ETF you name, and NQ, MNQ, ES and MES futures for signed-in accounts. The screener and the market scan run across a fixed list: about 1,400 US stocks today, chosen by dollar volume, of which about 1,180 are scanned on a given day (the rest are skipped when their data is incomplete). The list is today's. Companies that were delisted, taken over or fell out of it over the last ten years are not in it.
Fills and costs
| Rule | What happens |
|---|---|
| A rule fires on a close | The trade fills at the next bar's open. The script never sees a bar it has not reached. |
| Stops and limits | Fill at the prices the Pine runtime reports inside the bar; a limit the price gaps through fills at the open of that bar. |
| Gaps | The move from one close to the next open is counted while a position is held, for and against you. |
| Position size | One position at a time, long or short, the whole account; the script's initial capital is the account. |
| Commission | 0.05% of each fill's value by default, or the commission the script declares, which wins. |
| Slippage | 0.025% against you on each fill by default; a script's own slippage setting is applied by the runtime in its fills. |
| Not modelled | Partial fills, spread changes, market impact, borrow fees on shorts, margin interest and taxes. |
The default costs come to 0.15% for a round trip, a conservative figure for a liquid US stock and too little for a thin one. How to set your own.
How a result is judged
Every run reports net return against buying and holding the symbol, both after costs, with Sharpe, Sortino, a t-statistic on the mean trade, profit factor, win rate, worst drawdown, the yearly returns and the full list of trades, each marked on the chart.
| Check | The rule |
|---|---|
| Enough trades | Fewer than 20 trades or less than a year of bars: too few trades to judge, whatever the return. |
| Lost money | Net return at or below zero, profit factor under 1 or Sharpe at or below zero. |
| Could be luck | Made money, but the mean trade is not far enough from zero (t-statistic about 2 is the bar). |
| Real edge so far | Sharpe at least 0.5, t-statistic at least 1.5, worst drawdown under 45%. |
| Strong | Sharpe at least 1, t-statistic at least 2, profit factor at least 1.5, drawdown under 35%, and more than buy and hold. |
Then the held-out test. The last 33% of the bars is kept apart and judged on its own, with its dates: with fewer than five trades there, too few trades to judge; a Sharpe ratio at or below zero, did not survive; positive and at least half the fitted period's, survived; anything in between, decayed. The optimiser, on the Pro and Max plans, fits a script's inputs on the first part only, judges them on the held-out part, and shows the winner next to the best of the same number of random tries, so a result that random settings would also have found is not called an edge.
Before a script runs, the audit reads it line by line for 38 known failure modes: lookahead through request.security, entries inside an unconfirmed bar, alerts fired mid-bar, costs left at zero, dead version 4 syntax and others. A script can pass every check and still be a poor strategy; the audit rules out mechanics, not ideas.
Checking a result elsewhere
The same script, symbol, timeframe and date range give the same result on a later run; only new bars, or a split that re-adjusts history, change it. The script and every input are visible with the result. The signed-in tester exports the trade list as CSV: side, entry and exit dates and prices, and the return of each trade after costs, so the fills can be recomputed in a spreadsheet, or the same script run in TradingView's Strategy Tester with the same commission and slippage declared.
Expect small differences against TradingView: this tester runs Pine v6 on its own runtime and its own data, and TradingView charges no costs unless the script sets them. The two side by side.
What a result does not prove
A strategy that survived its held-out period held up on one later stretch of one symbol's history after modelled costs. That is not a forecast and not evidence of a live edge: the market changes, the costs you pay may differ, dividends are not in the return, the list of stocks flatters, and the strategy may have been tuned more often than the page can see. These are research tools, not investment advice.
Questions
From Alpaca's market data: the consolidated US tape for history, and IEX for the newest 15 minutes of a live session. Daily bars reach back to 2016, one-minute bars cover the last 120 sessions and five-minute bars the last 600, regular session by default.
No. Prices are adjusted for splits and not for dividends, so a result is a price return. A strategy that holds through many dividend dates earns less in the test than it would have in an account; a strategy that is often flat is barely affected.
In any run across the market, yes. The screener's universe is today's list of about 1,400 US stocks, and names that were delisted or dropped out of it are not in it, so a rule applied across that list looks better than it would have in real time. A backtest of one symbol you choose tests that symbol's own history, which is a different question.
A rule that fires on a bar's close fills at the next bar's open. Stops and limits fill at the prices the Pine runtime reports inside the bar. Every fill pays commission and slippage, 0.05% and 0.025% per side by default unless the script sets its own commission. Nothing else is modelled: no partial fills, no market impact, no borrow fees.
The last third of the bars is judged on its own. With fewer than five trades there it says too few trades to judge. Otherwise: did not survive when the held-out Sharpe ratio is zero or below, survived when it is positive and at least half the fitted period's, decayed in between. It is a test of the one period, not a forecast.
Yes. The same script, symbol, timeframe and date range give the same result on a later run (new bars or a split re-adjusting history are the only things that change it). The signed-in tester exports the trade list as CSV with every entry and exit, so the fills and costs can be recomputed in a spreadsheet or in another backtester.
Facts on this page come from the tester's own code and data (the bars function, the backtest engine, the Pine audit and the scan feed), read on 24 October 2026; the live scan feed listed a universe of 1,423 names with 1,183 scanned that day. Alpaca and IEX are the data providers named in our data agreements; TradingView and Pine Script belong to TradingView, Inc., and Alpha Charts is not affiliated with it.