Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (8)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$47,500$101,264Equity from $50,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. 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.
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

Verified

Same 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")

Clean v5

VerifiedDownload the v5 script

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.

SettingDefaultType and rangeFeeds
Basic settings
Entry length2int · min 1_lowest
Exit length2int · min 1_highest
Close after X candlesLeave 0 if you want this to be disabled.5intclose_all line 26 close_all
ATR settings
ATR entry multiplier0.0float · step 0.1_lowest
ATR exit multiplier0.0float · step 0.1_highest
ATR period20int · min 2unused
Date selection
Initial dateLeave this value as it is to disable.0intinRange
Final dateLeave this value as it is to disable.0intinRange

What it calculates

  • Lowest / ATR (lowest, ta.lowest in v5)Entry length (2)_lowest · line 15
  • Highest / ATR (highest, ta.highest in 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.

I_ENTRY_LENGTHEntry lengthsetting · 2I_ATR_ENTRY_MULTATR entry multipliersetting · 0.0I_EXIT_LENGTHExit lengthsetting · 2I_ATR_EXIT_MULTATR exit multipliersetting · 0.0timetimeprice dataI_INITIAL_DATEInitial datesetting · 0I_FINAL_DATEFinal datesetting · 0I_CLOSE_AFTERClose after X candlessetting · 5_lowestLowest / ATR→ _lowest_highestHighest / ATR→ _highestinRangeinRangevalueopenedopenedconditioninMarketinMarketconditionentry:LongOpen Longstrategy.entryexit:Longexit Longstrategy.exitclose_all:close_all strategy.close_allplot:19Entry priceplotplot:20Exit priceplot

Order rules

OrderFires whenBy defaultLine
Open Long longinRangeOn24
Exit Long limitevery barOn25
Close I_CLOSE_AFTER and barssince(opened) >= I_CLOSE_AFTEROn27

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.

43/43trades 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−5.0%+102.5%13664%0.9846.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−11.5%+5.5%13864%0.8226.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−62.8%+9.8%13665%0.7776.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−3.9%+8.4%13668%0.9528.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+36.9%+16.7%14467%1.0752.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+9.8%+21.5%14767%1.1031.9%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+10.7%+148.3%13365%1.0531.6%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+3.2%+17.1%14465%1.0419.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 barsTradesWonP&L
Rising market4271%$13,142.30
Sideways market5953%−$22,903.80
Falling market3574%$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.

0%60%
All 136 trades
SideEntryExitBarsP&L
long26 Jan 2024 41,823.5028 Jan 2024 42,246.802$506.07
long1 Feb 2024 42,276.805 Feb 2024 43,380.004$1,317.90
long17 Feb 2024 51,314.0019 Feb 2024 52,377.002$1,073.56
long20 Feb 2024 51,163.3020 Feb 2024 52,488.800$1,370.42
long21 Feb 2024 50,760.4025 Feb 2024 51,698.004$1,002.42
long5 Mar 2024 61,320.008 Mar 2024 67,980.003$6,002.95
long11 Mar 2024 67,861.1011 Mar 2024 69,887.600$1,829.78
long14 Mar 2024 68,620.8019 Mar 2024 61,937.405−$6,146.01
long1 Apr 2024 69,540.006 Apr 2024 69,309.905−$188.46
long9 Apr 2024 68,824.0014 Apr 2024 65,661.805−$2,608.27
long16 Apr 2024 62,134.0019 Apr 2024 64,499.003$2,061.50
long24 Apr 2024 64,500.0029 Apr 2024 63,866.005−$552.63
long1 May 2024 59,191.603 May 2024 60,841.602$1,551.84
long7 May 2024 62,700.0010 May 2024 63,429.003$665.33
long23 May 2024 68,842.2027 May 2024 69,610.004$645.62
long28 May 2024 68,128.002 Jun 2024 67,765.605−$311.34
long7 Jun 2024 70,117.6010 Jun 2024 69,857.103−$216.30
long11 Jun 2024 69,130.2016 Jun 2024 66,676.905−$2,058.52
long18 Jun 2024 65,130.0023 Jun 2024 63,210.005−$1,649.25
long28 Jun 2024 60,606.6030 Jun 2024 62,225.302$1,450.15
long3 Jul 2024 61,806.308 Jul 2024 56,714.605−$4,592.47
long12 Jul 2024 57,050.0013 Jul 2024 59,650.001$2,331.31
long23 Jul 2024 65,777.0026 Jul 2024 67,102.003$1,077.41
long29 Jul 2024 66,650.0029 Jul 2024 69,400.000$2,251.28
long30 Jul 2024 66,428.004 Aug 2024 58,161.005−$7,070.57
long11 Aug 2024 59,535.0014 Aug 2024 61,578.103$1,707.09
long15 Aug 2024 58,392.9018 Aug 2024 59,817.803$1,255.48
long19 Aug 2024 58,408.9020 Aug 2024 60,285.001$1,692.90
long26 Aug 2024 63,531.0031 Aug 2024 58,974.005−$3,902.00
long2 Sep 2024 57,201.003 Sep 2024 59,425.701$1,963.96
long4 Sep 2024 57,128.009 Sep 2024 55,318.005−$1,662.14
long16 Sep 2024 58,691.1017 Sep 2024 60,395.801$1,475.52
long26 Sep 2024 62,700.0026 Sep 2024 64,818.000$1,765.82
long30 Sep 2024 65,422.204 Oct 2024 62,390.304−$2,504.44
long9 Oct 2024 61,860.3011 Oct 2024 62,543.802$569.38
long21 Oct 2024 68,010.0024 Oct 2024 67,836.003−$133.30
long31 Oct 2024 69,760.005 Nov 2024 69,500.005−$193.70
long24 Nov 2024 97,122.1029 Nov 2024 97,208.205$45.90
long2 Dec 2024 95,693.904 Dec 2024 98,130.002$1,319.31
long5 Dec 2024 93,578.2010 Dec 2024 96,593.005$1,712.14
long18 Dec 2024 103,333.0023 Dec 2024 94,881.505−$4,486.60
long27 Dec 2024 95,199.1031 Dec 2024 95,340.004$74.53
long7 Jan 2025 97,276.8012 Jan 2025 94,545.105−$1,416.56
long19 Jan 2025 99,950.8020 Jan 2025 106,422.001$3,174.42
long26 Jan 2025 102,750.0029 Jan 2025 103,800.003$533.45
long1 Feb 2025 101,560.006 Feb 2025 96,554.405−$2,599.18
long9 Feb 2025 95,620.3010 Feb 2025 97,323.101$892.79
long12 Feb 2025 94,876.9014 Feb 2025 98,120.002$1,744.27
long16 Feb 2025 96,252.8020 Feb 2025 96,900.004$354.82
long21 Feb 2025 95,030.0026 Feb 2025 84,250.105−$6,026.62
long28 Feb 2025 82,256.002 Mar 2025 86,558.002$2,463.38
long4 Mar 2025 85,050.606 Mar 2025 91,000.002$3,467.09
long7 Mar 2025 86,334.5012 Mar 2025 84,123.505−$1,358.16
long18 Mar 2025 81,981.1019 Mar 2025 84,756.801$1,749.55
long27 Mar 2025 85,860.001 Apr 2025 83,943.105−$1,192.72
long3 Apr 2025 82,320.008 Apr 2025 76,322.405−$3,805.32
long16 Apr 2025 83,600.0019 Apr 2025 85,470.003$1,083.19
long20 Apr 2025 84,304.0021 Apr 2025 85,678.001$806.91
long28 Apr 2025 93,602.6028 Apr 2025 95,369.000$949.52
long4 May 2025 95,753.006 May 2025 96,304.502$295.25
long12 May 2025 102,819.0016 May 2025 104,357.004$771.34
long19 May 2025 102,613.0020 May 2025 107,109.001$2,292.96
long25 May 2025 106,800.0026 May 2025 109,506.001$1,384.03
long28 May 2025 107,517.002 Jun 2025 105,867.005−$859.35
long5 Jun 2025 104,179.008 Jun 2025 105,900.003$911.03
long12 Jun 2025 108,064.0016 Jun 2025 106,252.004−$940.00
long17 Jun 2025 104,495.0020 Jun 2025 105,550.003$556.89
long21 Jun 2025 102,345.0023 Jun 2025 103,983.002$890.89
long30 Jun 2025 106,812.002 Jul 2025 108,790.002$1,047.80
long7 Jul 2025 107,756.009 Jul 2025 109,700.002$1,039.25
long15 Jul 2025 117,225.0017 Jul 2025 120,064.002$1,420.54
long18 Jul 2025 117,017.0021 Jul 2025 118,857.003$944.38
long22 Jul 2025 116,467.0022 Jul 2025 119,677.000$1,681.63
long25 Jul 2025 117,103.0027 Jul 2025 118,452.002$722.02
long29 Jul 2025 117,428.003 Aug 2025 114,209.005−$1,738.43
long14 Aug 2025 118,207.0019 Aug 2025 112,873.005−$2,783.74
long21 Aug 2025 112,380.0022 Aug 2025 114,822.001$1,279.78
long24 Aug 2025 111,685.0028 Aug 2025 112,625.004$506.63
long29 Aug 2025 110,345.001 Sep 2025 109,480.003−$475.95
long15 Sep 2025 115,127.0015 Sep 2025 116,299.000$612.70
long22 Sep 2025 115,188.0027 Sep 2025 109,636.005−$2,931.77
long7 Oct 2025 122,136.0012 Oct 2025 114,959.005−$3,401.98
long16 Oct 2025 109,866.0019 Oct 2025 109,240.003−$310.48
long22 Oct 2025 107,403.0024 Oct 2025 111,294.002$1,962.88
long29 Oct 2025 112,211.002 Nov 2025 111,190.004−$510.84
long3 Nov 2025 109,395.008 Nov 2025 102,313.005−$3,601.43
long12 Nov 2025 102,476.0017 Nov 2025 92,215.105−$5,209.82
long19 Nov 2025 89,253.8023 Nov 2025 87,498.904−$920.55
long1 Dec 2025 90,155.502 Dec 2025 92,000.001$939.10
long5 Dec 2025 90,889.008 Dec 2025 91,760.003$448.87
long11 Dec 2025 89,500.0016 Dec 2025 87,863.405−$864.70
long18 Dec 2025 85,266.0022 Dec 2025 89,081.804$2,077.51
long23 Dec 2025 87,600.0026 Dec 2025 88,592.703$549.62
long29 Dec 2025 87,253.1029 Dec 2025 88,088.800$469.80
long7 Jan 2026 91,262.9012 Jan 2026 91,283.905$11.37
long16 Jan 2026 94,559.3021 Jan 2026 89,454.705−$2,673.84
long25 Jan 2026 88,578.4027 Jan 2026 89,319.102$391.87
long29 Jan 2026 87,304.303 Feb 2026 75,770.205−$6,242.34
long5 Feb 2026 71,888.008 Feb 2026 71,751.303−$77.96
long10 Feb 2026 68,308.0013 Feb 2026 69,292.903$590.13
long16 Feb 2026 68,000.0021 Feb 2026 68,318.405$194.40
long23 Feb 2026 67,190.0025 Feb 2026 67,684.902$307.23
long28 Feb 2026 64,914.502 Mar 2026 68,200.002$2,126.82
long7 Mar 2026 67,744.809 Mar 2026 68,551.002$525.42
long18 Mar 2026 72,270.4023 Mar 2026 71,100.905−$722.90
long26 Mar 2026 68,923.1030 Mar 2026 67,288.904−$1,042.04
long2 Apr 2026 65,998.105 Apr 2026 67,562.903$1,017.40
long12 Apr 2026 71,426.1013 Apr 2026 73,790.001$1,453.73
long16 Apr 2026 73,514.0017 Apr 2026 75,534.801$1,247.40
long19 Apr 2026 74,529.4021 Apr 2026 76,558.602$1,269.52
long27 Apr 2026 77,140.201 May 2026 77,904.904$474.80
long7 May 2026 79,808.7010 May 2026 81,080.003$770.51
long12 May 2026 80,279.8014 May 2026 81,788.002$923.24
long15 May 2026 78,754.6020 May 2026 77,800.005−$606.88
long22 May 2026 76,516.7025 May 2026 77,543.103$663.44
long26 May 2026 76,108.0031 May 2026 73,674.405−$1,602.67
long2 Jun 2026 70,686.707 Jun 2026 63,978.005−$4,604.80
long10 Jun 2026 60,780.0011 Jun 2026 63,526.001$1,984.02
long17 Jun 2026 65,354.0021 Jun 2026 64,388.004−$678.42
long23 Jun 2026 63,270.0028 Jun 2026 59,577.005−$2,639.42
long30 Jun 2026 58,900.001 Jul 2026 60,780.601$1,359.50
long6 Jul 2026 62,328.206 Jul 2026 63,999.000$1,177.84
long13 Jul 2026 63,640.8014 Jul 2026 64,425.001$555.93
long17 Jul 2026 63,748.7019 Jul 2026 64,865.002$799.76
long20 Jul 2026 63,886.7020 Jul 2026 64,967.300$786.07
long23 Jul 2026 65,148.8027 Jul 2026 65,577.004$310.66
long28 Jul 2026 63,605.6030 Jul 2026 64,744.802$852.03
long31 Jul 2026 63,267.303 Aug 2026 63,796.303$404.87
long10 Aug 2026 64,730.1015 Aug 2026 63,086.005−$1,240.15
long28 Aug 2026 77,632.602 Sep 2026 77,340.005−$179.34
long7 Sep 2026 79,233.0011 Sep 2026 79,760.004$315.32
long14 Sep 2026 76,500.0014 Sep 2026 77,505.700$627.36
long15 Sep 2026 76,388.7018 Sep 2026 77,179.503$500.50
long24 Sep 2026 83,500.0029 Sep 2026 83,663.705$95.74
long7 Oct 2026 84,972.0011 Oct 2026 83,529.004−$831.23
long12 Oct 2026 82,545.8017 Oct 2026 81,491.005−$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.

ScriptSharesTypeNetTradesMax drawdown
2HL this page—v4 strategy−5.0%13646.0%
Aggresive Scalper-Swing Crypto Strategy by exlux99lowest highest atrv4 strategy−7.4%316.0%
Donchian Channels Strategy by KrisWaters by kriswatershighest lowest atrv4 strategy+55.8%2123.3%
Chandelier Exit - Strategy by melihtunaatr highest lowestv4 strategy−34.8%1143.2%
ETF trader by FX_mindsatr lowest highestv4 strategy+78.3%1732.7%
Chandelier Exit by Zeal Terminalatr highest lowestv5 indicatorindicator

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 16 msWith a workaround 1,000 bars in 55 msNot measured
PineTSNo 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")