Pine Script v4 · Strategy
2HL
A Pine Script v4 strategy built on Lowest or ATR (2) and Highest or ATR (2). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a profit target and no stop loss. Each trade commits 100% of equity and pays no commission. 8 settings; defaults include Entry length 2, Exit length 2 and Close after X candles 5.
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 2HL repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 43 of 43 trades.
- How did 2HL do on BTCUSDT 1D with default settings?
- −5.00%
- From 26 Jan 2024 to 21 Oct 2026, over 136 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can 2HL 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 2HL use a stop loss?
- No
- Its exits set a profit target but no stop.
- Does 2HL run in Zeal Terminal?
- Yes
- It compiles in 16 ms and runs 1,000 bars in 55 ms, in the browser.
BTCUSDT · 1D · default settings
- Entry price
- Exit price
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −5.00%
- −$2,499.68
- Buy and hold
- +102.5%
- same period
- Closed trades
- 136
- 87 won · 49 lost
- Profitable
- 64.0%
- of closed trades
- Profit factor
- 0.98
- gross profit ÷ gross loss
- Max drawdown
- 46.04%
- −$29,197.10
One run with the author's default settings, $50,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
1 setting does nothing
“ATR period” is declared but never read.
-
Check
No stop loss
strategy.exit is used without a stop, loss or trailing stop.
-
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.
-
Note
Uses an argument v6 removed
when = on line 24. 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.
- Upgrading to v5 renames lowest → ta.lowest, atr → ta.atr, highest → ta.highest, barssince → ta.barssince, tostring → str.tostring.
- 1 strategy call uses the when = argument (line 24). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 136 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 1: //@version=4 → //@version=5
- Line 12: input(type = input.time) → input.time()
- Line 13: input(type = input.time) → input.time()
- Line 15: lowest → ta.lowest
- Line 15: atr → ta.atr
- Line 16: highest → ta.highest
4 more edits
- Line 16: atr → ta.atr
- Line 24: strategy.entry(…, true) → strategy.entry(…, strategy.long)
- Line 26: barssince → ta.barssince
- Line 27: tostring → str.tostring
-//@version=4+//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯var I_ATR_PERIOD = input(20, "ATR period", minval=2, inline="ATR settings", group="ATR settings")-var I_INITIAL_DATE = input(0, "Initial date", input.time, tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")+var I_INITIAL_DATE = input.time(0, "Initial date", tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")-var I_FINAL_DATE = input(0, "Final date", input.time, tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")+var I_FINAL_DATE = input.time(0, "Final date", tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")// Calculations-_lowest = lowest(I_ENTRY_LENGTH) - atr(I_ENTRY_LENGTH) * I_ATR_ENTRY_MULT+_lowest = ta.lowest(I_ENTRY_LENGTH) - ta.atr(I_ENTRY_LENGTH) * I_ATR_ENTRY_MULT-_highest = highest(I_EXIT_LENGTH) + atr(I_EXIT_LENGTH) * I_ATR_EXIT_MULT+_highest = ta.highest(I_EXIT_LENGTH) + ta.atr(I_EXIT_LENGTH) * I_ATR_EXIT_MULTinMarket = strategy.opentrades != 0⋯// Orders-strategy.entry("Long", true, limit=_lowest, comment="Entry long", when=inRange)+strategy.entry("Long", strategy.long, limit=_lowest, comment="Entry long", when=inRange)strategy.exit("Long", "Long", limit=_highest, comment="Exit long")-if I_CLOSE_AFTER and barssince(opened) >= I_CLOSE_AFTER+if I_CLOSE_AFTER and ta.barssince(opened) >= I_CLOSE_AFTER- strategy.close_all(comment="It has been " + tostring(I_CLOSE_AFTER) + " candle" + (I_CLOSE_AFTER > 1 ? "s" : "") + " since you entered")+ strategy.close_all(comment="It has been " + str.tostring(I_CLOSE_AFTER) + " candle" + (I_CLOSE_AFTER > 1 ? "s" : "") + " since you entered")Same 136 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 7: input() → input.int()
- Line 8: input() → input.int()
- Line 9: input() → input.float()
- Line 10: input() → input.float()
- Line 11: input() → input.int()
- Line 24: when = inRange → if block
⋯// Inputs-var I_ENTRY_LENGTH = input(2, "Entry length", minval=1, inline="Length", group="Basic settings")+var I_ENTRY_LENGTH = input.int(2, "Entry length", minval=1, inline="Length", group="Basic settings")-var I_EXIT_LENGTH = input(2, "Exit length", minval=1, inline="Length", group="Basic settings")+var I_EXIT_LENGTH = input.int(2, "Exit length", minval=1, inline="Length", group="Basic settings")-var I_CLOSE_AFTER = input(5, "Close after X candles", tooltip="Leave 0 if you want this to be disabled.", group="Basic settings")+var I_CLOSE_AFTER = input.int(5, "Close after X candles", tooltip="Leave 0 if you want this to be disabled.", group="Basic settings")-var I_ATR_ENTRY_MULT = input(0.0, "ATR entry multiplier", step=0.1, inline="ATR settings", group="ATR settings")+var I_ATR_ENTRY_MULT = input.float(0.0, "ATR entry multiplier", step=0.1, inline="ATR settings", group="ATR settings")-var I_ATR_EXIT_MULT = input(0.0, "ATR exit multiplier", step=0.1, inline="ATR settings", group="ATR settings")+var I_ATR_EXIT_MULT = input.float(0.0, "ATR exit multiplier", step=0.1, inline="ATR settings", group="ATR settings")-var I_ATR_PERIOD = input(20, "ATR period", minval=2, inline="ATR settings", group="ATR settings")+var I_ATR_PERIOD = input.int(20, "ATR period", minval=2, inline="ATR settings", group="ATR settings")var I_INITIAL_DATE = input.time(0, "Initial date", tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")⋯// Orders-strategy.entry("Long", strategy.long, limit=_lowest, comment="Entry long", when=inRange)+if inRange+ strategy.entry("Long", strategy.long, limit=_lowest, comment="Entry long")strategy.exit("Long", "Long", limit=_highest, comment="Exit long")⋯Does it run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L27:C3: cannot use 'int' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯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 |
|---|---|---|---|
| Basic settings | |||
| Entry length | 2 | int · min 1 | _lowest |
| Exit length | 2 | int · min 1 | _highest |
| Close after X candlesLeave 0 if you want this to be disabled. | 5 | int | close_all line 26 close_all |
| ATR settings | |||
| ATR entry multiplier | 0.0 | float · step 0.1 | _lowest |
| ATR exit multiplier | 0.0 | float · step 0.1 | _highest |
| ATR period | 20 | int · min 2 | unused |
| Date selection | |||
| Initial dateLeave this value as it is to disable. | 0 | int | inRange |
| Final dateLeave this value as it is to disable. | 0 | int | inRange |
What it calculates
- Lowest / ATR (
lowest,ta.lowestin v5)Entry length (2)_lowest · line 15 - Highest / ATR (
highest,ta.highestin v5)Exit length (2)_highest · line 16
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 | inRange | On | 24 |
| Exit Long limit | every bar | On | 25 |
| Close | I_CLOSE_AFTER and barssince(opened) >= I_CLOSE_AFTER | On | 27 |
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 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −5.0% | +102.5% | 136 | 64% | 0.98 | 46.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −11.5% | +5.5% | 138 | 64% | 0.82 | 26.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −62.8% | +9.8% | 136 | 65% | 0.77 | 76.5% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −3.9% | +8.4% | 136 | 68% | 0.95 | 28.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +36.9% | +16.7% | 144 | 67% | 1.07 | 52.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +9.8% | +21.5% | 147 | 67% | 1.10 | 31.9% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +10.7% | +148.3% | 133 | 65% | 1.05 | 31.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +3.2% | +17.1% | 144 | 65% | 1.04 | 19.3% | 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 | 42 | 71% | $13,142.30 |
| Sideways market | 59 | 53% | −$22,903.80 |
| Falling market | 35 | 74% | $7,261.82 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
51.9%
The 95th percentile of the worst drawdown when the same 136 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 27.8% to 51.9%; the tick is what actually happened, 35.5%. Order luck alone moves it this much.
All 136 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 26 Jan 2024 41,823.50 | 28 Jan 2024 42,246.80 | 2 | $506.07 |
| long | 1 Feb 2024 42,276.80 | 5 Feb 2024 43,380.00 | 4 | $1,317.90 |
| long | 17 Feb 2024 51,314.00 | 19 Feb 2024 52,377.00 | 2 | $1,073.56 |
| long | 20 Feb 2024 51,163.30 | 20 Feb 2024 52,488.80 | 0 | $1,370.42 |
| long | 21 Feb 2024 50,760.40 | 25 Feb 2024 51,698.00 | 4 | $1,002.42 |
| long | 5 Mar 2024 61,320.00 | 8 Mar 2024 67,980.00 | 3 | $6,002.95 |
| long | 11 Mar 2024 67,861.10 | 11 Mar 2024 69,887.60 | 0 | $1,829.78 |
| long | 14 Mar 2024 68,620.80 | 19 Mar 2024 61,937.40 | 5 | −$6,146.01 |
| long | 1 Apr 2024 69,540.00 | 6 Apr 2024 69,309.90 | 5 | −$188.46 |
| long | 9 Apr 2024 68,824.00 | 14 Apr 2024 65,661.80 | 5 | −$2,608.27 |
| long | 16 Apr 2024 62,134.00 | 19 Apr 2024 64,499.00 | 3 | $2,061.50 |
| long | 24 Apr 2024 64,500.00 | 29 Apr 2024 63,866.00 | 5 | −$552.63 |
| long | 1 May 2024 59,191.60 | 3 May 2024 60,841.60 | 2 | $1,551.84 |
| long | 7 May 2024 62,700.00 | 10 May 2024 63,429.00 | 3 | $665.33 |
| long | 23 May 2024 68,842.20 | 27 May 2024 69,610.00 | 4 | $645.62 |
| long | 28 May 2024 68,128.00 | 2 Jun 2024 67,765.60 | 5 | −$311.34 |
| long | 7 Jun 2024 70,117.60 | 10 Jun 2024 69,857.10 | 3 | −$216.30 |
| long | 11 Jun 2024 69,130.20 | 16 Jun 2024 66,676.90 | 5 | −$2,058.52 |
| long | 18 Jun 2024 65,130.00 | 23 Jun 2024 63,210.00 | 5 | −$1,649.25 |
| long | 28 Jun 2024 60,606.60 | 30 Jun 2024 62,225.30 | 2 | $1,450.15 |
| long | 3 Jul 2024 61,806.30 | 8 Jul 2024 56,714.60 | 5 | −$4,592.47 |
| long | 12 Jul 2024 57,050.00 | 13 Jul 2024 59,650.00 | 1 | $2,331.31 |
| long | 23 Jul 2024 65,777.00 | 26 Jul 2024 67,102.00 | 3 | $1,077.41 |
| long | 29 Jul 2024 66,650.00 | 29 Jul 2024 69,400.00 | 0 | $2,251.28 |
| long | 30 Jul 2024 66,428.00 | 4 Aug 2024 58,161.00 | 5 | −$7,070.57 |
| long | 11 Aug 2024 59,535.00 | 14 Aug 2024 61,578.10 | 3 | $1,707.09 |
| long | 15 Aug 2024 58,392.90 | 18 Aug 2024 59,817.80 | 3 | $1,255.48 |
| long | 19 Aug 2024 58,408.90 | 20 Aug 2024 60,285.00 | 1 | $1,692.90 |
| long | 26 Aug 2024 63,531.00 | 31 Aug 2024 58,974.00 | 5 | −$3,902.00 |
| long | 2 Sep 2024 57,201.00 | 3 Sep 2024 59,425.70 | 1 | $1,963.96 |
| long | 4 Sep 2024 57,128.00 | 9 Sep 2024 55,318.00 | 5 | −$1,662.14 |
| long | 16 Sep 2024 58,691.10 | 17 Sep 2024 60,395.80 | 1 | $1,475.52 |
| long | 26 Sep 2024 62,700.00 | 26 Sep 2024 64,818.00 | 0 | $1,765.82 |
| long | 30 Sep 2024 65,422.20 | 4 Oct 2024 62,390.30 | 4 | −$2,504.44 |
| long | 9 Oct 2024 61,860.30 | 11 Oct 2024 62,543.80 | 2 | $569.38 |
| long | 21 Oct 2024 68,010.00 | 24 Oct 2024 67,836.00 | 3 | −$133.30 |
| long | 31 Oct 2024 69,760.00 | 5 Nov 2024 69,500.00 | 5 | −$193.70 |
| long | 24 Nov 2024 97,122.10 | 29 Nov 2024 97,208.20 | 5 | $45.90 |
| long | 2 Dec 2024 95,693.90 | 4 Dec 2024 98,130.00 | 2 | $1,319.31 |
| long | 5 Dec 2024 93,578.20 | 10 Dec 2024 96,593.00 | 5 | $1,712.14 |
| long | 18 Dec 2024 103,333.00 | 23 Dec 2024 94,881.50 | 5 | −$4,486.60 |
| long | 27 Dec 2024 95,199.10 | 31 Dec 2024 95,340.00 | 4 | $74.53 |
| long | 7 Jan 2025 97,276.80 | 12 Jan 2025 94,545.10 | 5 | −$1,416.56 |
| long | 19 Jan 2025 99,950.80 | 20 Jan 2025 106,422.00 | 1 | $3,174.42 |
| long | 26 Jan 2025 102,750.00 | 29 Jan 2025 103,800.00 | 3 | $533.45 |
| long | 1 Feb 2025 101,560.00 | 6 Feb 2025 96,554.40 | 5 | −$2,599.18 |
| long | 9 Feb 2025 95,620.30 | 10 Feb 2025 97,323.10 | 1 | $892.79 |
| long | 12 Feb 2025 94,876.90 | 14 Feb 2025 98,120.00 | 2 | $1,744.27 |
| long | 16 Feb 2025 96,252.80 | 20 Feb 2025 96,900.00 | 4 | $354.82 |
| long | 21 Feb 2025 95,030.00 | 26 Feb 2025 84,250.10 | 5 | −$6,026.62 |
| long | 28 Feb 2025 82,256.00 | 2 Mar 2025 86,558.00 | 2 | $2,463.38 |
| long | 4 Mar 2025 85,050.60 | 6 Mar 2025 91,000.00 | 2 | $3,467.09 |
| long | 7 Mar 2025 86,334.50 | 12 Mar 2025 84,123.50 | 5 | −$1,358.16 |
| long | 18 Mar 2025 81,981.10 | 19 Mar 2025 84,756.80 | 1 | $1,749.55 |
| long | 27 Mar 2025 85,860.00 | 1 Apr 2025 83,943.10 | 5 | −$1,192.72 |
| long | 3 Apr 2025 82,320.00 | 8 Apr 2025 76,322.40 | 5 | −$3,805.32 |
| long | 16 Apr 2025 83,600.00 | 19 Apr 2025 85,470.00 | 3 | $1,083.19 |
| long | 20 Apr 2025 84,304.00 | 21 Apr 2025 85,678.00 | 1 | $806.91 |
| long | 28 Apr 2025 93,602.60 | 28 Apr 2025 95,369.00 | 0 | $949.52 |
| long | 4 May 2025 95,753.00 | 6 May 2025 96,304.50 | 2 | $295.25 |
| long | 12 May 2025 102,819.00 | 16 May 2025 104,357.00 | 4 | $771.34 |
| long | 19 May 2025 102,613.00 | 20 May 2025 107,109.00 | 1 | $2,292.96 |
| long | 25 May 2025 106,800.00 | 26 May 2025 109,506.00 | 1 | $1,384.03 |
| long | 28 May 2025 107,517.00 | 2 Jun 2025 105,867.00 | 5 | −$859.35 |
| long | 5 Jun 2025 104,179.00 | 8 Jun 2025 105,900.00 | 3 | $911.03 |
| long | 12 Jun 2025 108,064.00 | 16 Jun 2025 106,252.00 | 4 | −$940.00 |
| long | 17 Jun 2025 104,495.00 | 20 Jun 2025 105,550.00 | 3 | $556.89 |
| long | 21 Jun 2025 102,345.00 | 23 Jun 2025 103,983.00 | 2 | $890.89 |
| long | 30 Jun 2025 106,812.00 | 2 Jul 2025 108,790.00 | 2 | $1,047.80 |
| long | 7 Jul 2025 107,756.00 | 9 Jul 2025 109,700.00 | 2 | $1,039.25 |
| long | 15 Jul 2025 117,225.00 | 17 Jul 2025 120,064.00 | 2 | $1,420.54 |
| long | 18 Jul 2025 117,017.00 | 21 Jul 2025 118,857.00 | 3 | $944.38 |
| long | 22 Jul 2025 116,467.00 | 22 Jul 2025 119,677.00 | 0 | $1,681.63 |
| long | 25 Jul 2025 117,103.00 | 27 Jul 2025 118,452.00 | 2 | $722.02 |
| long | 29 Jul 2025 117,428.00 | 3 Aug 2025 114,209.00 | 5 | −$1,738.43 |
| long | 14 Aug 2025 118,207.00 | 19 Aug 2025 112,873.00 | 5 | −$2,783.74 |
| long | 21 Aug 2025 112,380.00 | 22 Aug 2025 114,822.00 | 1 | $1,279.78 |
| long | 24 Aug 2025 111,685.00 | 28 Aug 2025 112,625.00 | 4 | $506.63 |
| long | 29 Aug 2025 110,345.00 | 1 Sep 2025 109,480.00 | 3 | −$475.95 |
| long | 15 Sep 2025 115,127.00 | 15 Sep 2025 116,299.00 | 0 | $612.70 |
| long | 22 Sep 2025 115,188.00 | 27 Sep 2025 109,636.00 | 5 | −$2,931.77 |
| long | 7 Oct 2025 122,136.00 | 12 Oct 2025 114,959.00 | 5 | −$3,401.98 |
| long | 16 Oct 2025 109,866.00 | 19 Oct 2025 109,240.00 | 3 | −$310.48 |
| long | 22 Oct 2025 107,403.00 | 24 Oct 2025 111,294.00 | 2 | $1,962.88 |
| long | 29 Oct 2025 112,211.00 | 2 Nov 2025 111,190.00 | 4 | −$510.84 |
| long | 3 Nov 2025 109,395.00 | 8 Nov 2025 102,313.00 | 5 | −$3,601.43 |
| long | 12 Nov 2025 102,476.00 | 17 Nov 2025 92,215.10 | 5 | −$5,209.82 |
| long | 19 Nov 2025 89,253.80 | 23 Nov 2025 87,498.90 | 4 | −$920.55 |
| long | 1 Dec 2025 90,155.50 | 2 Dec 2025 92,000.00 | 1 | $939.10 |
| long | 5 Dec 2025 90,889.00 | 8 Dec 2025 91,760.00 | 3 | $448.87 |
| long | 11 Dec 2025 89,500.00 | 16 Dec 2025 87,863.40 | 5 | −$864.70 |
| long | 18 Dec 2025 85,266.00 | 22 Dec 2025 89,081.80 | 4 | $2,077.51 |
| long | 23 Dec 2025 87,600.00 | 26 Dec 2025 88,592.70 | 3 | $549.62 |
| long | 29 Dec 2025 87,253.10 | 29 Dec 2025 88,088.80 | 0 | $469.80 |
| long | 7 Jan 2026 91,262.90 | 12 Jan 2026 91,283.90 | 5 | $11.37 |
| long | 16 Jan 2026 94,559.30 | 21 Jan 2026 89,454.70 | 5 | −$2,673.84 |
| long | 25 Jan 2026 88,578.40 | 27 Jan 2026 89,319.10 | 2 | $391.87 |
| long | 29 Jan 2026 87,304.30 | 3 Feb 2026 75,770.20 | 5 | −$6,242.34 |
| long | 5 Feb 2026 71,888.00 | 8 Feb 2026 71,751.30 | 3 | −$77.96 |
| long | 10 Feb 2026 68,308.00 | 13 Feb 2026 69,292.90 | 3 | $590.13 |
| long | 16 Feb 2026 68,000.00 | 21 Feb 2026 68,318.40 | 5 | $194.40 |
| long | 23 Feb 2026 67,190.00 | 25 Feb 2026 67,684.90 | 2 | $307.23 |
| long | 28 Feb 2026 64,914.50 | 2 Mar 2026 68,200.00 | 2 | $2,126.82 |
| long | 7 Mar 2026 67,744.80 | 9 Mar 2026 68,551.00 | 2 | $525.42 |
| long | 18 Mar 2026 72,270.40 | 23 Mar 2026 71,100.90 | 5 | −$722.90 |
| long | 26 Mar 2026 68,923.10 | 30 Mar 2026 67,288.90 | 4 | −$1,042.04 |
| long | 2 Apr 2026 65,998.10 | 5 Apr 2026 67,562.90 | 3 | $1,017.40 |
| long | 12 Apr 2026 71,426.10 | 13 Apr 2026 73,790.00 | 1 | $1,453.73 |
| long | 16 Apr 2026 73,514.00 | 17 Apr 2026 75,534.80 | 1 | $1,247.40 |
| long | 19 Apr 2026 74,529.40 | 21 Apr 2026 76,558.60 | 2 | $1,269.52 |
| long | 27 Apr 2026 77,140.20 | 1 May 2026 77,904.90 | 4 | $474.80 |
| long | 7 May 2026 79,808.70 | 10 May 2026 81,080.00 | 3 | $770.51 |
| long | 12 May 2026 80,279.80 | 14 May 2026 81,788.00 | 2 | $923.24 |
| long | 15 May 2026 78,754.60 | 20 May 2026 77,800.00 | 5 | −$606.88 |
| long | 22 May 2026 76,516.70 | 25 May 2026 77,543.10 | 3 | $663.44 |
| long | 26 May 2026 76,108.00 | 31 May 2026 73,674.40 | 5 | −$1,602.67 |
| long | 2 Jun 2026 70,686.70 | 7 Jun 2026 63,978.00 | 5 | −$4,604.80 |
| long | 10 Jun 2026 60,780.00 | 11 Jun 2026 63,526.00 | 1 | $1,984.02 |
| long | 17 Jun 2026 65,354.00 | 21 Jun 2026 64,388.00 | 4 | −$678.42 |
| long | 23 Jun 2026 63,270.00 | 28 Jun 2026 59,577.00 | 5 | −$2,639.42 |
| long | 30 Jun 2026 58,900.00 | 1 Jul 2026 60,780.60 | 1 | $1,359.50 |
| long | 6 Jul 2026 62,328.20 | 6 Jul 2026 63,999.00 | 0 | $1,177.84 |
| long | 13 Jul 2026 63,640.80 | 14 Jul 2026 64,425.00 | 1 | $555.93 |
| long | 17 Jul 2026 63,748.70 | 19 Jul 2026 64,865.00 | 2 | $799.76 |
| long | 20 Jul 2026 63,886.70 | 20 Jul 2026 64,967.30 | 0 | $786.07 |
| long | 23 Jul 2026 65,148.80 | 27 Jul 2026 65,577.00 | 4 | $310.66 |
| long | 28 Jul 2026 63,605.60 | 30 Jul 2026 64,744.80 | 2 | $852.03 |
| long | 31 Jul 2026 63,267.30 | 3 Aug 2026 63,796.30 | 3 | $404.87 |
| long | 10 Aug 2026 64,730.10 | 15 Aug 2026 63,086.00 | 5 | −$1,240.15 |
| long | 28 Aug 2026 77,632.60 | 2 Sep 2026 77,340.00 | 5 | −$179.34 |
| long | 7 Sep 2026 79,233.00 | 11 Sep 2026 79,760.00 | 4 | $315.32 |
| long | 14 Sep 2026 76,500.00 | 14 Sep 2026 77,505.70 | 0 | $627.36 |
| long | 15 Sep 2026 76,388.70 | 18 Sep 2026 77,179.50 | 3 | $500.50 |
| long | 24 Sep 2026 83,500.00 | 29 Sep 2026 83,663.70 | 5 | $95.74 |
| long | 7 Oct 2026 84,972.00 | 11 Oct 2026 83,529.00 | 4 | −$831.23 |
| long | 12 Oct 2026 82,545.80 | 17 Oct 2026 81,491.00 | 5 | −$614.82 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| 2HL this page | — | v4 strategy | −5.0% | 136 | 46.0% |
| Aggresive Scalper-Swing Crypto Strategy by exlux99 | lowest highest atr | v4 strategy | −7.4% | 3 | 16.0% |
| Donchian Channels Strategy by KrisWaters by kriswaters | highest lowest atr | v4 strategy | +55.8% | 21 | 23.3% |
| Chandelier Exit - Strategy by melihtuna | atr highest lowest | v4 strategy | −34.8% | 11 | 43.2% |
| ETF trader by FX_minds | atr lowest highest | v4 strategy | +78.3% | 17 | 32.7% |
| Chandelier Exit by Zeal Terminal | atr highest lowest | v5 indicator | indicator | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 16 ms | With a workaround 1,000 bars in 55 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 24) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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.
//@version=4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Coded by Eduardo Mattjestrategy("Highs and lows", "HsLs", true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=50000, process_orders_on_close=true)// Inputsvar I_ENTRY_LENGTH = input(2, "Entry length", minval=1, inline="Length", group="Basic settings")var I_EXIT_LENGTH = input(2, "Exit length", minval=1, inline="Length", group="Basic settings")var I_CLOSE_AFTER = input(5, "Close after X candles", tooltip="Leave 0 if you want this to be disabled.", group="Basic settings")var I_ATR_ENTRY_MULT = input(0.0, "ATR entry multiplier", step=0.1, inline="ATR settings", group="ATR settings")var I_ATR_EXIT_MULT = input(0.0, "ATR exit multiplier", step=0.1, inline="ATR settings", group="ATR settings")var I_ATR_PERIOD = input(20, "ATR period", minval=2, inline="ATR settings", group="ATR settings")var I_INITIAL_DATE = input(0, "Initial date", input.time, tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")var I_FINAL_DATE = input(0, "Final date", input.time, tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")// Calculations_lowest = lowest(I_ENTRY_LENGTH) - atr(I_ENTRY_LENGTH) * I_ATR_ENTRY_MULT_highest = highest(I_EXIT_LENGTH) + atr(I_EXIT_LENGTH) * I_ATR_EXIT_MULTinMarket = strategy.opentrades != 0opened = strategy.opentrades[0] > strategy.opentrades[1]plot(not inMarket or not inMarket[1] ? _lowest[1] : na, "Entry price", color.red, 2, plot.style_linebr, offset=0)plot(inMarket or inMarket[1] ? _highest[1] : na, "Exit price", color.teal, 2, plot.style_linebr, offset=0)// Range checkinRange = (I_INITIAL_DATE == 0 ? true : time >= I_INITIAL_DATE) and (I_FINAL_DATE == 0 ? true : time <= I_FINAL_DATE)// Ordersstrategy.entry("Long", true, limit=_lowest, comment="Entry long", when=inRange)strategy.exit("Long", "Long", limit=_highest, comment="Exit long")if I_CLOSE_AFTER and barssince(opened) >= I_CLOSE_AFTER strategy.close_all(comment="It has been " + tostring(I_CLOSE_AFTER) + " candle" + (I_CLOSE_AFTER > 1 ? "s" : "") + " since you entered")