Pine Script v5 · Strategy
Backtests Are Broken
A Pine Script v5 strategy with no technical-analysis calculation. It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. It has no settings.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does Backtests Are Broken repaint?
- Yes
- In a live replay, it did not match history on 13 of 13 trades, and it produced 10 trades that history does not have.
- How did Backtests Are Broken do on BTCUSDT 1D with default settings?
- +1.32%
- From 26 Jan 2024 to 21 Oct 2026, over 45 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Backtests Are Broken run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 50 before, 42 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does Backtests Are Broken use a stop loss?
- Yes
- strategy.exit sets a stop on line 7.
- Does Backtests Are Broken run in Zeal Terminal?
- Yes
- It compiles in 6 ms and runs 1,000 bars in 12 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +1.32%
- $13,162.60
- Buy and hold
- +102.5%
- same period
- Closed trades
- 45
- 30 won · 2 lost
- Profitable
- 66.7%
- of closed trades
- Profit factor
- 14,790.40
- gross profit ÷ gross loss
- Max drawdown
- 0.18%
- −$1,781.57
One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
The script declares no settings.
What it calculates
No technical-analysis calculation: the script works on prices and settings directly.
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | strategy.position_size == 0 and math.random(0,100) < 5 | On | 6 |
| Exit Close Long stop | strategy.position_size == 0 and math.random(0,100) < 5 | On | 7 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
Yes
The live replay did not match history.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +1.3% | +102.5% | 45 | 67% | 14,790.40 | 0.2% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.5% | +5.5% | 43 | 77% | — | 0.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.1% | +9.8% | 52 | 75% | 4,878.22 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 55 | 75% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 54 | 70% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 40 | 80% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 46 | 63% | 1,088.39 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 46 | 63% | 5,702.00 | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 15 | 67% | $4,595.21 |
| Sideways market | 23 | 65% | $2,068.84 |
| Falling market | 7 | 71% | $6,498.56 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
0.0%
The 95th percentile of the worst drawdown when the same 45 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.0% to 0.0%; the tick is what actually happened, 0.0%. Order luck alone moves it this much.
All 45 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 27 Jan 2024 41,823.50 | 27 Jan 2024 41,823.50 | 0 | $0.01 |
| long | 2 Feb 2024 43,082.90 | 2 Feb 2024 43,082.90 | 0 | $0.00 |
| long | 9 Mar 2024 68,124.20 | 9 Mar 2024 68,124.20 | 0 | $0.00 |
| long | 19 Mar 2024 67,610.00 | 19 Mar 2024 67,610.00 | 0 | $0.00 |
| long | 9 Apr 2024 71,620.00 | 9 Apr 2024 71,620.00 | 0 | $0.01 |
| long | 22 Apr 2024 64,941.20 | 23 Apr 2024 66,819.30 | 1 | $1,878.17 |
| long | 5 May 2024 63,892.00 | 5 May 2024 63,892.10 | 0 | $0.02 |
| long | 17 May 2024 65,235.20 | 18 May 2024 67,024.00 | 1 | $1,788.79 |
| long | 30 May 2024 67,652.40 | 31 May 2024 68,352.20 | 1 | $699.76 |
| long | 1 Jun 2024 67,540.00 | 2 Jun 2024 67,766.80 | 1 | $226.83 |
| long | 5 Jul 2024 57,050.00 | 5 Jul 2024 57,050.00 | 0 | $0.00 |
| long | 19 Aug 2024 58,427.30 | 20 Aug 2024 59,438.50 | 1 | $1,011.15 |
| long | 29 Aug 2024 59,034.90 | 30 Aug 2024 59,359.00 | 1 | $324.10 |
| long | 12 Sep 2024 57,338.00 | 13 Sep 2024 58,132.30 | 1 | $794.31 |
| long | 25 Sep 2024 64,262.70 | 25 Sep 2024 64,262.70 | 0 | $0.01 |
| long | 18 Dec 2024 106,134.00 | 18 Dec 2024 106,134.00 | 0 | $0.01 |
| long | 29 Dec 2024 95,300.00 | 29 Dec 2024 95,300.00 | 0 | $0.01 |
| long | 20 Jan 2025 101,332.00 | 21 Jan 2025 102,260.00 | 1 | $928.43 |
| long | 13 Feb 2025 97,870.00 | 13 Feb 2025 97,870.00 | 0 | $0.00 |
| long | 17 Mar 2025 82,574.50 | 18 Mar 2025 84,010.00 | 1 | $1,435.50 |
| long | 20 Mar 2025 86,845.90 | 20 Mar 2025 86,845.90 | 0 | $0.02 |
| long | 25 Mar 2025 87,498.20 | 25 Mar 2025 87,498.20 | 0 | $0.01 |
| long | 26 Mar 2025 87,392.90 | 26 Mar 2025 87,392.90 | 0 | $0.00 |
| long | 24 Apr 2025 93,691.10 | 24 Apr 2025 93,691.10 | 0 | $0.02 |
| long | 2 Jun 2025 105,643.00 | 2 Jun 2025 105,643.00 | 0 | $0.01 |
| long | 9 Jun 2025 105,734.00 | 9 Jun 2025 105,734.00 | 0 | $0.00 |
| long | 22 Jun 2025 102,120.00 | 22 Jun 2025 102,120.00 | 0 | $0.00 |
| long | 5 Aug 2025 115,055.00 | 5 Aug 2025 115,055.00 | 0 | $0.01 |
| long | 17 Aug 2025 117,381.00 | 18 Aug 2025 117,405.00 | 1 | $24.35 |
| long | 25 Aug 2025 113,494.00 | 25 Aug 2025 113,494.00 | 0 | $0.01 |
| long | 5 Sep 2025 110,731.00 | 5 Sep 2025 110,731.00 | 0 | $0.01 |
| long | 9 Sep 2025 112,065.00 | 9 Sep 2025 112,065.00 | 0 | $0.01 |
| long | 23 Sep 2025 112,651.00 | 23 Sep 2025 112,651.00 | 0 | $0.01 |
| long | 6 Oct 2025 123,482.00 | 6 Oct 2025 123,482.00 | 0 | $0.00 |
| long | 8 Nov 2025 103,339.00 | 8 Nov 2025 103,339.00 | 0 | $0.00 |
| long | 12 Nov 2025 103,059.00 | 12 Nov 2025 103,059.00 | 0 | $0.00 |
| long | 26 Nov 2025 87,370.00 | 26 Nov 2025 87,370.00 | 0 | $0.00 |
| long | 16 Dec 2025 86,432.10 | 17 Dec 2025 87,863.40 | 1 | $1,431.35 |
| long | 19 Dec 2025 85,516.40 | 20 Dec 2025 88,136.90 | 1 | $2,620.54 |
| long | 15 Feb 2026 69,822.90 | 15 Feb 2026 69,823.00 | 0 | $0.02 |
| long | 13 May 2026 80,504.50 | 13 May 2026 80,504.50 | 0 | $0.01 |
| long | 23 Jun 2026 64,020.00 | 23 Jun 2026 64,020.00 | 0 | $0.01 |
| long | 26 Jun 2026 59,794.60 | 26 Jun 2026 59,794.00 | 0 | −$0.63 |
| long | 29 Aug 2026 77,845.90 | 29 Aug 2026 77,845.90 | 0 | $0.00 |
| long | 17 Oct 2026 81,615.90 | 17 Oct 2026 81,615.60 | 0 | −$0.26 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 50 before, 42 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// Copyright ©2022 and_then_it_CRASHED-//@version=5+//@version=6strategy("Backtest Broken", overlay=true, margin_long=1, margin_short=1)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 6 ms | Yes 1,000 bars in 12 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// Copyright ©2022 and_then_it_CRASHED//@version=5strategy("Backtest Broken", overlay=true, margin_long=1, margin_short=1)if strategy.position_size == 0 and math.random(0,100) < 5 strategy.entry('Long', strategy.long) strategy.exit('Close Long', 'Long', trail_price = close+syminfo.mintick, trail_offset = 0)