Zeal Terminal Open in Zeal Terminal

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
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,013,160$2,025,273Equity from $1,000,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. The live re-run is not offered here: the browser bundle did not reproduce the prerendered run.
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.

entry:LongOpen Longstrategy.entryexit:Close Longexit Close Longstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open Long longstrategy.position_size == 0 and math.random(0,100) < 5On6
Exit Close Long stopstrategy.position_size == 0 and math.random(0,100) < 5On7

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.

0/13trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+1.3%+102.5%4567%14,790.400.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.5%+5.5%4377%—0.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.1%+9.8%5275%4,878.220.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%5575%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%5470%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%4080%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%4663%1,088.390.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%4663%5,702.000.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 barsTradesWonP&L
Rising market1567%$4,595.21
Sideways market2365%$2,068.84
Falling market771%$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.

0%1%
All 45 trades
SideEntryExitBarsP&L
long27 Jan 2024 41,823.5027 Jan 2024 41,823.500$0.01
long2 Feb 2024 43,082.902 Feb 2024 43,082.900$0.00
long9 Mar 2024 68,124.209 Mar 2024 68,124.200$0.00
long19 Mar 2024 67,610.0019 Mar 2024 67,610.000$0.00
long9 Apr 2024 71,620.009 Apr 2024 71,620.000$0.01
long22 Apr 2024 64,941.2023 Apr 2024 66,819.301$1,878.17
long5 May 2024 63,892.005 May 2024 63,892.100$0.02
long17 May 2024 65,235.2018 May 2024 67,024.001$1,788.79
long30 May 2024 67,652.4031 May 2024 68,352.201$699.76
long1 Jun 2024 67,540.002 Jun 2024 67,766.801$226.83
long5 Jul 2024 57,050.005 Jul 2024 57,050.000$0.00
long19 Aug 2024 58,427.3020 Aug 2024 59,438.501$1,011.15
long29 Aug 2024 59,034.9030 Aug 2024 59,359.001$324.10
long12 Sep 2024 57,338.0013 Sep 2024 58,132.301$794.31
long25 Sep 2024 64,262.7025 Sep 2024 64,262.700$0.01
long18 Dec 2024 106,134.0018 Dec 2024 106,134.000$0.01
long29 Dec 2024 95,300.0029 Dec 2024 95,300.000$0.01
long20 Jan 2025 101,332.0021 Jan 2025 102,260.001$928.43
long13 Feb 2025 97,870.0013 Feb 2025 97,870.000$0.00
long17 Mar 2025 82,574.5018 Mar 2025 84,010.001$1,435.50
long20 Mar 2025 86,845.9020 Mar 2025 86,845.900$0.02
long25 Mar 2025 87,498.2025 Mar 2025 87,498.200$0.01
long26 Mar 2025 87,392.9026 Mar 2025 87,392.900$0.00
long24 Apr 2025 93,691.1024 Apr 2025 93,691.100$0.02
long2 Jun 2025 105,643.002 Jun 2025 105,643.000$0.01
long9 Jun 2025 105,734.009 Jun 2025 105,734.000$0.00
long22 Jun 2025 102,120.0022 Jun 2025 102,120.000$0.00
long5 Aug 2025 115,055.005 Aug 2025 115,055.000$0.01
long17 Aug 2025 117,381.0018 Aug 2025 117,405.001$24.35
long25 Aug 2025 113,494.0025 Aug 2025 113,494.000$0.01
long5 Sep 2025 110,731.005 Sep 2025 110,731.000$0.01
long9 Sep 2025 112,065.009 Sep 2025 112,065.000$0.01
long23 Sep 2025 112,651.0023 Sep 2025 112,651.000$0.01
long6 Oct 2025 123,482.006 Oct 2025 123,482.000$0.00
long8 Nov 2025 103,339.008 Nov 2025 103,339.000$0.00
long12 Nov 2025 103,059.0012 Nov 2025 103,059.000$0.00
long26 Nov 2025 87,370.0026 Nov 2025 87,370.000$0.00
long16 Dec 2025 86,432.1017 Dec 2025 87,863.401$1,431.35
long19 Dec 2025 85,516.4020 Dec 2025 88,136.901$2,620.54
long15 Feb 2026 69,822.9015 Feb 2026 69,823.000$0.02
long13 May 2026 80,504.5013 May 2026 80,504.500$0.01
long23 Jun 2026 64,020.0023 Jun 2026 64,020.000$0.01
long26 Jun 2026 59,794.6026 Jun 2026 59,794.000−$0.63
long29 Aug 2026 77,845.9029 Aug 2026 77,845.900$0.00
long17 Oct 2026 81,615.9017 Oct 2026 81,615.600−$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

Verified

Nothing 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

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 6 msYes 1,000 bars in 12 msNot measured
PineTSNot testedNot testedNot 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)