Pine Script v4 · Strategy
Crypto Long only Strategy 3h+ timeframe
A Pine Script v4 strategy with no technical-analysis calculation. It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.1% commission. 1 setting; defaults include Risk 25.
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 Crypto Long only Strategy 3h+ timeframe repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
- How did Crypto Long only Strategy 3h+ timeframe do on BTCUSDT 1D with default settings?
- −26.92%
- From 26 Jan 2024 to 21 Oct 2026, over 23 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Crypto Long only Strategy 3h+ timeframe 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 Crypto Long only Strategy 3h+ timeframe use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Crypto Long only Strategy 3h+ timeframe run in Zeal Terminal?
- Yes
- It compiles in 7 ms and runs 1,000 bars in 24 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −26.92%
- −$269.24
- Buy and hold
- +102.5%
- same period
- Closed trades
- 23
- 7 won · 16 lost
- Profitable
- 30.4%
- of closed trades
- Profit factor
- 0.71
- gross profit ÷ gross loss
- Max drawdown
- 38.56%
- −$452.99
One run with the author's default settings, $1,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 stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
1 setting has no label
In the settings dialog risk (line 14) shows an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses an argument v6 removed
when = on line 10, 13. The upgraded version below moves each call inside an if block.
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.
- 2 strategy calls use the when = argument (line 10, 13). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 23 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 10: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
⋯// © SoftKill21-//@version=4+//@version=5strategy("My Script", initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )⋯plot(candela, color=long? color.green : short? color.red : color.white ,linewidth=4)-strategy.entry("long",1,when=long)+strategy.entry("long",strategy.long,when=long)//strategy.entry('short',0,when=short)⋯Same 23 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 10: when = long → if block
- Line 13: when = short → if block
- Line 14: input() → input.int()
⋯plot(candela, color=long? color.green : short? color.red : color.white ,linewidth=4)-strategy.entry("long",strategy.long,when=long)+if long+ strategy.entry("long",strategy.long)//strategy.entry('short',0,when=short) -strategy.close("long", when = short)+if short+ strategy.close("long")-risk= input(25)+risk= input.int(25)strategy.risk.max_intraday_loss(risk, strategy.percent_of_equity)⋯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: 23 before, 37 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.
⋯// © SoftKill21-//@version=5+//@version=6strategy("My Script", initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Risk (no label in the script) | 25 | int | line 15 |
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 | longcandela > candela[1] and candela[1] > candela[2] and candela[2] > candela[3] and candela[3] > candela[4] and candela[4] > candela[5] | On | 10 |
| Close long | shortcandela< candela[1] and candela[1] < candela[2] and candela[2] < candela[3] and candela[3] < candela[4] | On | 13 |
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.
- 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 | −26.9% | +102.5% | 23 | 30% | 0.71 | 38.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +8.9% | +5.5% | 16 | 31% | 1.39 | 8.3% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −14.2% | +9.8% | 20 | 40% | 0.89 | 62.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +8.7% | +8.4% | 15 | 40% | 1.27 | 20.3% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −29.0% | +16.7% | 21 | 43% | 0.74 | 54.3% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +42.7% | +21.5% | 15 | 47% | 3.51 | 8.7% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +53.8% | +148.3% | 22 | 36% | 1.62 | 22.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +3.5% | +17.1% | 17 | 41% | 1.18 | 6.9% | 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 | 8 | 50% | $12.95 |
| Sideways market | 11 | 18% | −$263.11 |
| Falling market | 4 | 25% | −$19.08 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
54.0%
The 95th percentile of the worst drawdown when the same 23 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 31.5% to 54.0%; the tick is what actually happened, 37.8%. Order luck alone moves it this much.
All 23 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 10 Feb 2024 47,132.80 | 24 Feb 2024 50,744.20 | 14 | $74.47 |
| long | 29 Feb 2024 62,432.10 | 18 Mar 2024 68,393.50 | 18 | $100.25 |
| long | 9 Apr 2024 71,620.00 | 28 Apr 2024 63,462.00 | 19 | −$135.89 |
| long | 17 May 2024 65,235.20 | 15 Jun 2024 66,044.00 | 29 | $10.78 |
| long | 18 Jul 2024 64,088.00 | 3 Aug 2024 61,498.30 | 16 | −$44.42 |
| long | 25 Aug 2024 64,157.00 | 8 Sep 2024 54,160.90 | 14 | −$158.31 |
| long | 22 Sep 2024 63,349.00 | 3 Oct 2024 60,649.30 | 11 | −$37.71 |
| long | 10 Nov 2024 76,677.50 | 27 Nov 2024 91,965.20 | 17 | $159.39 |
| long | 9 Dec 2024 101,110.00 | 30 Dec 2024 93,738.20 | 21 | −$72.41 |
| long | 5 Jan 2025 98,220.50 | 4 Feb 2025 101,329.00 | 30 | $26.51 |
| long | 14 Apr 2025 83,760.00 | 31 May 2025 103,985.00 | 47 | $220.50 |
| long | 14 Jul 2025 119,087.00 | 1 Aug 2025 115,764.00 | 18 | −$34.11 |
| long | 12 Sep 2025 115,483.00 | 23 Sep 2025 112,651.00 | 11 | −$29.36 |
| long | 2 Oct 2025 118,595.00 | 11 Oct 2025 112,774.00 | 9 | −$55.04 |
| long | 28 Oct 2025 114,108.00 | 15 Nov 2025 94,594.00 | 18 | −$176.92 |
| long | 28 Nov 2025 91,333.90 | 15 Dec 2025 88,172.20 | 17 | −$30.98 |
| long | 5 Jan 2026 91,529.70 | 22 Jan 2026 89,454.70 | 17 | −$20.11 |
| long | 6 Mar 2026 70,891.00 | 22 Mar 2026 68,918.10 | 16 | −$23.72 |
| long | 9 Apr 2026 71,069.90 | 1 May 2026 76,346.60 | 22 | $55.73 |
| long | 6 May 2026 80,905.50 | 19 May 2026 77,001.90 | 13 | −$41.56 |
| long | 16 Jun 2026 66,328.70 | 20 Jun 2026 63,543.90 | 4 | −$34.55 |
| long | 6 Jul 2026 63,650.00 | 14 Aug 2026 63,490.90 | 39 | −$3.38 |
| long | 22 Aug 2026 78,338.00 | 11 Sep 2026 76,568.70 | 20 | −$18.38 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 7 ms | With a workaround 1,000 bars in 24 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as 1 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 10) so the engine trades the way the script says.
“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/// © SoftKill21//@version=4strategy("My Script", initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )var candela = 0.0candela := (high+low+open+close)/4long = candela > candela[1] and candela[1] > candela[2] and candela[2] > candela[3] and candela[3] > candela[4] and candela[4] > candela[5]short = candela< candela[1] and candela[1] < candela[2] and candela[2] < candela[3] and candela[3] < candela[4] //and candela[4] < candela[5] plot(candela, color=long? color.green : short? color.red : color.white ,linewidth=4)strategy.entry("long",1,when=long)//strategy.entry('short',0,when=short) strategy.close("long", when = short)risk= input(25)strategy.risk.max_intraday_loss(risk, strategy.percent_of_equity)//strategy.close("short", when = not long or short)