Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Buy-and-hold strategy stats

A Pine Script v4 strategy with no technical-analysis calculation. It has 2 order rules, 1 entry among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 3 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 Buy-and-hold strategy stats repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 299 of 299 trades.
How did Buy-and-hold strategy stats do on BTCUSDT 1D with default settings?
+102.53%
From 26 Jan 2024 to 21 Oct 2026, over 999 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Buy-and-hold strategy stats be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does Buy-and-hold strategy stats use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Buy-and-hold strategy stats run in Zeal Terminal?
Yes
It compiles in 5 ms and runs 1,000 bars in 20 ms, in the browser.

BTCUSDT · 1D · default settings

  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (3)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$20,252$20,253Equity from $10,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.
Net profit
+102.53%
$10,252.70
Buy and hold
+102.5%
same period
Closed trades
999
507 won · 492 lost
Profitable
50.8%
of closed trades
Profit factor
1.06
gross profit ÷ gross loss
Max drawdown
53.63%
−$15,985.80

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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 stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

v4 → v5

VerifiedDownload the v5 script

Same 999 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 5: input(type = input.time) → input.time()
  • Line 6: input(type = input.time) → input.time()
  • Line 7: input(type = input.bool) → input.bool()
⋯// © TradersForecast-//@version=4+//@version=5strategy("Buy-and-hold strategy stats", overlay=true, pyramiding=1, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, process_orders_on_close=true)-minDate = input(timestamp("01 Jan 2010 0:0 -0500"), title = "Start Date/Time", type = input.time)+minDate = input.time(timestamp("01 Jan 2010 0:0 -0500"), title = "Start Date/Time")-maxDate = input(timestamp("01 Jan 2030 0:0 -0500"), title = "End Date/Time", type = input.time)+maxDate = input.time(timestamp("01 Jan 2030 0:0 -0500"), title = "End Date/Time")-revTrd = input(false, title="Short position? (else it defaults to LONG)", type=input.bool)+revTrd = input.bool(false, title="Short position? (else it defaults to LONG)")strategy.close_all()⋯

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Yes

Same 999 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © TradersForecast-//@version=5+//@version=6strategy("Buy-and-hold strategy stats", overlay=true, pyramiding=1, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, process_orders_on_close=true)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Start Date/Timetimestamp("01 Jan 2010 0:0 -0500")timeentry My Long Entry Id line 9
End Date/Timetimestamp("01 Jan 2030 0:0 -0500")timeentry My Long Entry Id line 9
Short position? (else it defaults to LONG)falseboolentry My Long Entry Id

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.

timetimeprice dataminDateStart Date/Timesetting · timestamp("01 Jan 2…maxDateEnd Date/Timesetting · timestamp("01 Jan 2…close_all:close_all strategy.close_allentry:My Long Entry IdOpen My Long Entry Idstrategy.entry

Order rules

OrderFires whenBy defaultLine
Close every barOn8
Open My Long Entry Id revTrd ? strategy.short : strategy.longtime >= minDate and time <= maxDateOn10

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

299/299trades 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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+102.5%+102.5%99951%1.0653.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+5.5%+5.5%99951%1.0229.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+9.8%+9.8%99951%1.0168.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+8.4%+8.4%99951%1.0336.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+16.7%+16.7%99950%1.0177.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+21.5%+21.5%99948%1.0538.8%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+148.3%+148.3%99953%1.0758.9%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+17.1%+17.1%99952%1.0627.4%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 market34452%$11,241.20
Sideways market43149%−$3,774.99
Falling market22452%$2,786.48

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

62.2%

The 95th percentile of the worst drawdown when the same 999 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 33.8% to 62.2%; the tick is what actually happened, 53.0%. Order luck alone moves it this much.

0%72%
The first 150 of 999 trades
SideEntryExitBarsP&L
long26 Jan 2024 41,823.5027 Jan 2024 42,120.601$71.04
long27 Jan 2024 42,120.6028 Jan 2024 42,031.101−$21.42
long28 Jan 2024 42,031.1029 Jan 2024 43,302.701$304.05
long29 Jan 2024 43,302.7030 Jan 2024 42,941.101−$86.46
long30 Jan 2024 42,941.1031 Jan 2024 42,580.001−$86.34
long31 Jan 2024 42,580.001 Feb 2024 43,082.901$120.25
long1 Feb 2024 43,082.902 Feb 2024 43,200.001$27.99
long2 Feb 2024 43,200.003 Feb 2024 43,011.101−$45.17
long3 Feb 2024 43,011.104 Feb 2024 42,582.901−$102.39
long4 Feb 2024 42,582.905 Feb 2024 42,708.701$30.08
long5 Feb 2024 42,708.706 Feb 2024 43,098.901$93.31
long6 Feb 2024 43,098.907 Feb 2024 44,349.601$299.03
long7 Feb 2024 44,349.608 Feb 2024 45,288.701$224.53
long8 Feb 2024 45,288.709 Feb 2024 47,132.801$440.93
long9 Feb 2024 47,132.8010 Feb 2024 47,751.101$147.84
long10 Feb 2024 47,751.1011 Feb 2024 48,300.001$131.24
long11 Feb 2024 48,300.0012 Feb 2024 49,917.301$386.69
long12 Feb 2024 49,917.3013 Feb 2024 49,699.601−$52.05
long13 Feb 2024 49,699.6014 Feb 2024 51,795.201$501.05
long14 Feb 2024 51,795.2015 Feb 2024 51,880.001$20.28
long15 Feb 2024 51,880.0016 Feb 2024 52,124.101$58.37
long16 Feb 2024 52,124.1017 Feb 2024 51,642.601−$115.12
long17 Feb 2024 51,642.6018 Feb 2024 52,137.701$118.36
long18 Feb 2024 52,137.7019 Feb 2024 51,774.701−$86.78
long19 Feb 2024 51,774.7020 Feb 2024 52,258.801$115.75
long20 Feb 2024 52,258.8021 Feb 2024 51,849.401−$97.89
long21 Feb 2024 51,849.4022 Feb 2024 51,288.401−$134.13
long22 Feb 2024 51,288.4023 Feb 2024 50,744.201−$130.13
long23 Feb 2024 50,744.2024 Feb 2024 51,568.201$197.03
long24 Feb 2024 51,568.2025 Feb 2024 51,728.801$38.41
long25 Feb 2024 51,728.8026 Feb 2024 54,476.501$656.96
long26 Feb 2024 54,476.5027 Feb 2024 57,037.301$612.30
long27 Feb 2024 57,037.3028 Feb 2024 62,432.101$1,289.89
long28 Feb 2024 62,432.1029 Feb 2024 61,131.001−$311.10
long29 Feb 2024 61,131.001 Mar 2024 62,387.901$300.53
long1 Mar 2024 62,387.902 Mar 2024 61,987.301−$95.79
long2 Mar 2024 61,987.303 Mar 2024 63,114.001$269.39
long3 Mar 2024 63,114.004 Mar 2024 68,245.701$1,227.00
long4 Mar 2024 68,245.705 Mar 2024 63,724.001−$1,081.14
long5 Mar 2024 63,724.006 Mar 2024 66,074.001$561.89
long6 Mar 2024 66,074.007 Mar 2024 66,823.201$179.12
long7 Mar 2024 66,823.208 Mar 2024 68,124.201$311.07
long8 Mar 2024 68,124.209 Mar 2024 68,313.301$45.21
long9 Mar 2024 68,313.3010 Mar 2024 68,955.901$153.65
long10 Mar 2024 68,955.9011 Mar 2024 72,078.101$746.52
long11 Mar 2024 72,078.1012 Mar 2024 71,452.001−$149.70
long12 Mar 2024 71,452.0013 Mar 2024 73,072.401$387.44
long13 Mar 2024 73,072.4014 Mar 2024 71,388.901−$402.52
long14 Mar 2024 71,388.9015 Mar 2024 69,499.901−$451.68
long15 Mar 2024 69,499.9016 Mar 2024 65,300.601−$1,004.03
long16 Mar 2024 65,300.6017 Mar 2024 68,393.501$739.50
long17 Mar 2024 68,393.5018 Mar 2024 67,610.001−$187.33
long18 Mar 2024 67,610.0019 Mar 2024 61,937.401−$1,356.32
long19 Mar 2024 61,937.4020 Mar 2024 67,840.501$1,411.43
long20 Mar 2024 67,840.5021 Mar 2024 65,501.301−$559.31
long21 Mar 2024 65,501.3022 Mar 2024 63,796.601−$407.58
long22 Mar 2024 63,796.6023 Mar 2024 63,990.001$46.23
long23 Mar 2024 63,990.0024 Mar 2024 67,210.001$769.90
long24 Mar 2024 67,210.0025 Mar 2024 69,880.001$638.40
long25 Mar 2024 69,880.0026 Mar 2024 69,988.001$25.82
long26 Mar 2024 69,988.0027 Mar 2024 69,470.001−$123.86
long27 Mar 2024 69,470.0028 Mar 2024 70,780.601$313.37
long28 Mar 2024 70,780.6029 Mar 2024 69,850.501−$222.38
long29 Mar 2024 69,850.5030 Mar 2024 69,582.201−$64.16
long30 Mar 2024 69,582.2031 Mar 2024 71,280.001$405.95
long31 Mar 2024 71,280.001 Apr 2024 69,649.801−$389.78
long1 Apr 2024 69,649.802 Apr 2024 65,464.001−$1,000.83
long2 Apr 2024 65,464.003 Apr 2024 65,963.301$119.38
long3 Apr 2024 65,963.304 Apr 2024 68,487.801$603.61
long4 Apr 2024 68,487.805 Apr 2024 67,820.601−$159.52
long5 Apr 2024 67,820.606 Apr 2024 68,896.001$257.12
long6 Apr 2024 68,896.007 Apr 2024 69,360.401$111.04
long7 Apr 2024 69,360.408 Apr 2024 71,620.001$540.27
long8 Apr 2024 71,620.009 Apr 2024 69,146.001−$591.53
long9 Apr 2024 69,146.0010 Apr 2024 70,631.101$355.08
long10 Apr 2024 70,631.1011 Apr 2024 70,006.201−$149.40
long11 Apr 2024 70,006.2012 Apr 2024 67,116.501−$690.93
long12 Apr 2024 67,116.5013 Apr 2024 63,924.501−$763.21
long13 Apr 2024 63,924.5014 Apr 2024 65,661.801$415.40
long14 Apr 2024 65,661.8015 Apr 2024 63,420.001−$536.03
long15 Apr 2024 63,420.0016 Apr 2024 63,793.401$89.28
long16 Apr 2024 63,793.4017 Apr 2024 61,277.401−$601.58
long17 Apr 2024 61,277.4018 Apr 2024 63,470.101$524.28
long18 Apr 2024 63,470.1019 Apr 2024 63,818.001$83.19
long19 Apr 2024 63,818.0020 Apr 2024 64,940.601$268.41
long20 Apr 2024 64,940.6021 Apr 2024 64,941.201$0.13
long21 Apr 2024 64,941.2022 Apr 2024 66,819.301$449.07
long22 Apr 2024 66,819.3023 Apr 2024 66,414.001−$96.91
long23 Apr 2024 66,414.0024 Apr 2024 64,289.601−$507.95
long24 Apr 2024 64,289.6025 Apr 2024 64,498.301$49.91
long25 Apr 2024 64,498.3026 Apr 2024 63,770.001−$174.14
long26 Apr 2024 63,770.0027 Apr 2024 63,462.001−$73.65
long27 Apr 2024 63,462.0028 Apr 2024 63,118.601−$82.10
long28 Apr 2024 63,118.6029 Apr 2024 63,866.001$178.70
long29 Apr 2024 63,866.0030 Apr 2024 60,672.001−$763.68
long30 Apr 2024 60,672.001 May 2024 58,365.001−$551.61
long1 May 2024 58,365.002 May 2024 59,060.601$166.33
long2 May 2024 59,060.603 May 2024 62,882.001$913.70
long3 May 2024 62,882.004 May 2024 63,892.001$241.50
long4 May 2024 63,892.005 May 2024 64,012.001$28.68
long5 May 2024 64,012.006 May 2024 63,165.201−$202.47
long6 May 2024 63,165.207 May 2024 62,312.101−$203.98
long7 May 2024 62,312.108 May 2024 61,193.001−$267.56
long8 May 2024 61,193.009 May 2024 63,074.001$449.74
long9 May 2024 63,074.0010 May 2024 60,800.001−$543.72
long10 May 2024 60,800.0011 May 2024 60,826.001$6.22
long11 May 2024 60,826.0012 May 2024 61,484.001$157.33
long12 May 2024 61,484.0013 May 2024 62,940.101$348.15
long13 May 2024 62,940.1014 May 2024 61,577.501−$325.80
long14 May 2024 61,577.5015 May 2024 66,206.501$1,106.80
long15 May 2024 66,206.5016 May 2024 65,235.201−$232.24
long16 May 2024 65,235.2017 May 2024 67,024.001$427.70
long17 May 2024 67,024.0018 May 2024 66,915.201−$26.01
long18 May 2024 66,915.2019 May 2024 66,274.001−$153.31
long19 May 2024 66,274.0020 May 2024 71,446.601$1,236.77
long20 May 2024 71,446.6021 May 2024 70,148.301−$310.42
long21 May 2024 70,148.3022 May 2024 69,166.601−$234.73
long22 May 2024 69,166.6023 May 2024 67,969.601−$286.19
long23 May 2024 67,969.6024 May 2024 68,550.001$138.76
long24 May 2024 68,550.0025 May 2024 69,290.601$177.07
long25 May 2024 69,290.6026 May 2024 68,507.701−$187.19
long26 May 2024 68,507.7027 May 2024 69,436.401$222.07
long27 May 2024 69,436.4028 May 2024 68,398.401−$248.19
long28 May 2024 68,398.4029 May 2024 67,652.401−$178.36
long29 May 2024 67,652.4030 May 2024 68,352.201$167.31
long30 May 2024 68,352.2031 May 2024 67,540.001−$194.19
long31 May 2024 67,540.001 Jun 2024 67,766.901$54.24
long1 Jun 2024 67,766.902 Jun 2024 67,765.601−$0.29
long2 Jun 2024 67,765.603 Jun 2024 68,809.901$249.69
long3 Jun 2024 68,809.904 Jun 2024 70,537.801$413.15
long4 Jun 2024 70,537.805 Jun 2024 71,108.001$136.32
long5 Jun 2024 71,108.006 Jun 2024 70,799.101−$73.87
long6 Jun 2024 70,799.107 Jun 2024 69,355.601−$345.13
long7 Jun 2024 69,355.608 Jun 2024 69,310.501−$10.79
long8 Jun 2024 69,310.509 Jun 2024 69,648.101$80.74
long9 Jun 2024 69,648.1010 Jun 2024 69,540.001−$25.86
long10 Jun 2024 69,540.0011 Jun 2024 67,314.201−$532.18
long11 Jun 2024 67,314.2012 Jun 2024 68,264.001$227.09
long12 Jun 2024 68,264.0013 Jun 2024 66,773.001−$356.49
long13 Jun 2024 66,773.0014 Jun 2024 66,044.001−$174.31
long14 Jun 2024 66,044.0015 Jun 2024 66,228.301$44.06
long15 Jun 2024 66,228.3016 Jun 2024 66,676.901$107.27
long16 Jun 2024 66,676.9017 Jun 2024 66,504.301−$41.25
long17 Jun 2024 66,504.3018 Jun 2024 65,175.301−$317.77
long18 Jun 2024 65,175.3019 Jun 2024 64,974.401−$48.05
long19 Jun 2024 64,974.4020 Jun 2024 64,870.001−$24.96
long20 Jun 2024 64,870.0021 Jun 2024 64,143.601−$173.69
long21 Jun 2024 64,143.6022 Jun 2024 64,262.001$28.32
long22 Jun 2024 64,262.0023 Jun 2024 63,210.001−$251.53
long23 Jun 2024 63,210.0024 Jun 2024 60,293.301−$697.38

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 5 msYes 1,000 bars in 20 msNot measured
PineTSNo v5 and v6 only—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. PineTS runs Pine Script v5 and v6 only.

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/// © TradersForecast//@version=4strategy("Buy-and-hold strategy stats", overlay=true, pyramiding=1, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, process_orders_on_close=true)minDate = input(timestamp("01 Jan 2010 0:0 -0500"), title = "Start Date/Time", type = input.time)maxDate = input(timestamp("01 Jan 2030 0:0 -0500"), title = "End Date/Time", type = input.time)revTrd = input(false, title="Short position? (else it defaults to LONG)", type=input.bool)strategy.close_all()if time >= minDate and time <= maxDate    strategy.entry("My Long Entry Id", revTrd ? strategy.short : strategy.long)