OPEN-SOURCE SCRIPT

Taught to Trade - Backtest Integrity Scanner

219
🔵 OVERVIEW

This does not read your strategy. It measures the chart your strategy is being tested on, and reports which standard backtest assumptions are unsafe here.

Most backtest failures are not logic errors. They are assumptions about the instrument: that costs are negligible, that the sample is large enough, that the data is clean, that the test window contains more than one market regime. Those are properties of the chart rather than of your code, and they can be measured directly.

The table reports ten of them and flags the ones that need attention.

🔵 HOW TO READ THE TABLE

Header shows bars available and years of history on this chart and timeframe.

Approx trades available. Bars divided by your assumed holding period. Flags CHECK below the minimum you set. Expectancy measured on a handful of trades is not measurable.

Median bar range. The middle bar's high to low as a percentage of price. This is what one bar is worth here.

Round-trip cost. Your commission plus slippage, both sides.

Cost / median bar. The number that matters most. It is the fraction of a typical bar's entire range consumed by entering and exiting once. On a 15-minute crypto chart with ordinary retail costs this routinely exceeds 50 percent. A strategy whose average win is smaller than a median bar cannot survive that, and no amount of parameter tuning changes it.

One-bar head start. The average absolute distance from one bar's close to the next bar's open, as a percentage. This is what a same-bar lookahead error is worth on this instrument.

Head start / cost. The head start expressed in round trips. Above 1.0x, a one-bar lookahead bug hands a backtest more than a full round trip of free edge per trade, which is enough to invent an edge out of nothing.

Zero-volume bars. Bars where nothing traded. A backtest will happily fill you on them.

Gaps above the ATR multiple. Bars that opened far from the previous close. Stops and limits behave very differently across these than a backtest assumes.

Volatility regime now. Current ATR percentile band, plus the share of the sample sitting in the high and low thirds. Flags CHECK when one regime dominates, because an edge measured inside a single regime is a regime bet.

🔵 SETTINGS

Cost assumptions: commission and slippage per side. Use your broker's real numbers. Zero slippage is the most common dishonest backtest setting.

Sample: window length, assumed bars held per trade, and the minimum trade count you would accept.

Data checks: ATR length, the gap threshold, and the cost share at which the warning fires.

Table: position and text size.

🔵 ALERTS

Four alert conditions are provided and none fire on their own. You configure them yourself in the alerts dialog. This script does not send buy or sell signals and never will.

🔵 WHERE IT FAILS

This tool is about limits, so it should be honest about its own.

It cannot see your strategy. It has no access to your entry logic, your fills, or your equity curve. It measures the environment, which means a table full of OK does not mean your backtest is honest. It means these particular environmental assumptions are not the thing breaking it.

The cost inputs are yours. Enter a fantasy number and you get a fantasy verdict. The script cannot verify what you actually pay.

Median bar range is a poor summary of a fat-tailed distribution. It deliberately ignores the tails, and the tails are where a lot of real outcomes live.

The one-bar head start figure is an average across the sample. On the individual bars that matter most, the violent ones, it is far larger than the average suggests.

The regime split uses ATR terciles computed inside the same window it is judging. On a short window that is close to circular, and it will call a quiet sample balanced when the market simply has not moved yet.

The trade count is an estimate from a holding period you typed in, not from a real trade list.

Data checks are limited to what TradingView provides for the symbol. Survivorship bias in your symbol universe is invisible here, and it is one of the largest backtest errors there is.

Open source, so you can read every calculation rather than take any of this on trust.

Educational tool only, not investment advice. It does not predict anything and does not generate signals. Trading involves substantial risk of loss.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。