Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

ETF trader

A Pine Script v4 strategy built on ATR (14), Lowest (close, 4) and Highest (close, 4). It has 23 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade commits 100% of equity and pays no commission. 9 settings; defaults include HH LL lookback 20, ATR period 14 and ATR SL multiplier 2.

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 ETF trader repaint?
No
No repainting patterns were found in the source. The live replay was not measured: the script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script.
How did ETF trader do on BTCUSDT 1D with default settings?
+78.30%
From 26 Jan 2024 to 21 Oct 2026, over 17 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can ETF trader be converted to Pine Script v5?
No
The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
Does ETF trader use a stop loss?
Yes
strategy.exit sets a stop on line 56, 60.
Does ETF trader run in Zeal Terminal?
Yes
It compiles in 37 ms and runs 1,000 bars in 44 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • 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 (9)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$178,302$202,527Equity from $100,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. 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
+78.30%
$78,302.80
Buy and hold
+102.5%
same period
Closed trades
17
6 won · 11 lost
Profitable
35.3%
of closed trades
Profit factor
1.59
gross profit ÷ gross loss
Max drawdown
32.74%
−$70,577.10

One run with the author's default settings, $100,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.

  • 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.

  • Upgrading to v5 renames crossover → ta.crossover, highest → ta.highest, crossunder → ta.crossunder, lowest → ta.lowest, atr → ta.atr, tostring → str.tostring.

v4 → v5

Differs

Trades differ: 17 before, 17 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 6: input(type = input.integer) → input.int()
  • Line 7: input(type = input.integer) → input.int()
  • Line 8: input(type = input.float) → input.float()
  • Line 9: input(type = input.float) → input.float()
  • Line 10: input(type = input.float) → input.float()
40 more edits
  • Line 11: input(type = input.integer) → input.int()
  • Line 12: input(type = input.float) → input.float()
  • Line 13: input(type = input.bool) → input.bool()
  • Line 14: input(type = input.bool) → input.bool()
  • Line 16: crossover → ta.crossover
  • Line 16: highest → ta.highest
  • Line 17: crossunder → ta.crossunder
  • Line 17: lowest → ta.lowest
  • Line 38: atr → ta.atr
  • Line 39: atr → ta.atr
  • Line 40: atr → ta.atr
  • Line 43: lowest → ta.lowest
  • Line 44: highest → ta.highest
  • Line 45: crossover → ta.crossover
  • Line 46: crossunder → ta.crossunder
  • Line 55: tostring → str.tostring
  • Line 56: tostring → str.tostring
  • Line 57: tostring → str.tostring
  • Line 59: tostring → str.tostring
  • Line 60: tostring → str.tostring
  • Line 61: tostring → str.tostring
  • Line 65: tostring → str.tostring
  • Line 66: tostring → str.tostring
  • Line 67: tostring → str.tostring
  • Line 68: tostring → str.tostring
  • Line 69: tostring → str.tostring
  • Line 70: tostring → str.tostring
  • Line 71: tostring → str.tostring
  • Line 72: tostring → str.tostring
  • Line 73: tostring → str.tostring
  • Line 76: tostring → str.tostring
  • Line 77: tostring → str.tostring
  • Line 78: tostring → str.tostring
  • Line 79: tostring → str.tostring
  • Line 80: tostring → str.tostring
  • Line 81: tostring → str.tostring
  • Line 82: tostring → str.tostring
  • Line 83: tostring → str.tostring
  • Line 84: tostring → str.tostring
  • Line 85: tostring → str.tostring
⋯// © FX_minds-//@version=4+//@version=5strategy("ETF trader", overlay=true, pyramiding=100, default_qty_type=strategy.percent_of_equity, default_qty_value=100)//------------------------------ get user input-lookback                   = input(title="HH LL lookback", type=input.integer, defval=20)+lookback                   = input.int(title="HH LL lookback", defval=20)-ATR_periode                = input(title="ATR period", type=input.integer, defval=14)+ATR_periode                = input.int(title="ATR period", defval=14)-ATR_SL_multiplier          = input(title="ATR SL multiplier", type=input.float, defval=2)+ATR_SL_multiplier          = input.float(title="ATR SL multiplier", defval=2)-ATR_TP_multiplier          = input(title="ATR TP multiplier", type=input.float, defval=1)+ATR_TP_multiplier          = input.float(title="ATR TP multiplier", defval=1)-trailing_SL_ATR_multiplier = input(title="ATR trailing SL multiplier", type=input.float, defval=3.5)+trailing_SL_ATR_multiplier = input.float(title="ATR trailing SL multiplier", defval=3.5)-lookback_trailing_SL       = input(title="trailing SL lookback", type=input.integer, defval=4)+lookback_trailing_SL       = input.int(title="trailing SL lookback", defval=4)-max_sequel_trades          = input(title="max sequel trades", type=input.float, defval=1)+max_sequel_trades          = input.float(title="max sequel trades", defval=1)-trade_long                 = input(title= "trade long ?", type=input.bool, defval=true)+trade_long                 = input.bool(title= "trade long ?", defval=true)-trade_short                = input(title= "trade short ?", type=input.bool, defval=false)+trade_short                = input.bool(title= "trade short ?", defval=false)//------------------------------ determine entry conditions-long_condition   = barstate.isconfirmed and crossover(high, highest(high, lookback)[1])+long_condition   = barstate.isconfirmed and ta.crossover(high, ta.highest(high, lookback)[1])-short_condition  = barstate.isconfirmed and crossunder(low, lowest(low, lookback)[1])+short_condition  = barstate.isconfirmed and ta.crossunder(low, ta.lowest(low, lookback)[1])//------------------------------ count open long trades⋯//------------------------------ calculate SL & TP-SL_distance = atr(ATR_periode) * ATR_SL_multiplier+SL_distance = ta.atr(ATR_periode) * ATR_SL_multiplier-TP_distance  = atr(ATR_periode) * ATR_TP_multiplier+TP_distance  = ta.atr(ATR_periode) * ATR_TP_multiplier-trailing_SL_distance = atr(ATR_periode) * trailing_SL_ATR_multiplier+trailing_SL_distance = ta.atr(ATR_periode) * trailing_SL_ATR_multiplierSL_long = entryprice_long - SL_distanceSL_short = entryprice_short + SL_distance-trailing_SL_short = lowest(close, lookback_trailing_SL) + trailing_SL_distance+trailing_SL_short = ta.lowest(close, lookback_trailing_SL) + trailing_SL_distance-trailing_SL_long  = highest(close, lookback_trailing_SL) - trailing_SL_distance+trailing_SL_long  = ta.highest(close, lookback_trailing_SL) - trailing_SL_distance-trailing_SL_short_signal = crossover(high, trailing_SL_short[1])+trailing_SL_short_signal = ta.crossover(high, trailing_SL_short[1])-trailing_SL_long_signal = crossunder(low, trailing_SL_long[1])+trailing_SL_long_signal = ta.crossunder(low, trailing_SL_long[1])//------------------------------ plot entry price & SL  ⋯if (long_condition) and (count_open_longs <= max_sequel_trades) and (trade_long == true)-    strategy.entry("Long" + tostring(count_open_longs, "#"), strategy.long)+    strategy.entry("Long" + str.tostring(count_open_longs, "#"), strategy.long)-    strategy.exit("SL Long"+ tostring(count_open_longs, "#"), +    strategy.exit("SL Long"+ str.tostring(count_open_longs, "#"), -     from_entry="Long" + tostring(count_open_longs, "#"), stop=SL_long)+     from_entry="Long" + str.tostring(count_open_longs, "#"), stop=SL_long)if (short_condition) and (count_open_shorts <= max_sequel_trades) and (trade_short == true)-    strategy.entry("Short" + tostring(count_open_shorts, "#"), strategy.short)+    strategy.entry("Short" + str.tostring(count_open_shorts, "#"), strategy.short)-    strategy.exit("SL Short" + tostring(count_open_shorts, "#"), +    strategy.exit("SL Short" + str.tostring(count_open_shorts, "#"), -     from_entry="Short" + tostring(count_open_shorts, "#"), stop=SL_short)+     from_entry="Short" + str.tostring(count_open_shorts, "#"), stop=SL_short)    ⋯if (trailing_SL_long_signal)-    strategy.close("Long" + tostring(count_open_longs, "#"))+    strategy.close("Long" + str.tostring(count_open_longs, "#"))-    strategy.close("Long" + tostring(count_open_longs-1, "#"))+    strategy.close("Long" + str.tostring(count_open_longs-1, "#"))-    strategy.close("Long" + tostring(count_open_longs-2, "#"))+    strategy.close("Long" + str.tostring(count_open_longs-2, "#"))-    strategy.close("Long" + tostring(count_open_longs-4, "#"))+    strategy.close("Long" + str.tostring(count_open_longs-4, "#"))-    strategy.close("Long" + tostring(count_open_longs-5, "#"))+    strategy.close("Long" + str.tostring(count_open_longs-5, "#"))-    strategy.close("Long" + tostring(count_open_longs-6, "#"))+    strategy.close("Long" + str.tostring(count_open_longs-6, "#"))-    strategy.close("Long" + tostring(count_open_longs-7, "#"))+    strategy.close("Long" + str.tostring(count_open_longs-7, "#"))-    strategy.close("Long" + tostring(count_open_longs-8, "#"))+    strategy.close("Long" + str.tostring(count_open_longs-8, "#"))-    strategy.close("Long" + tostring(count_open_longs-9, "#"))+    strategy.close("Long" + str.tostring(count_open_longs-9, "#"))    if (trailing_SL_short_signal)-    strategy.close("Short" + tostring(count_open_shorts, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts, "#"))-    strategy.close("Short" + tostring(count_open_shorts-1, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-1, "#"))-    strategy.close("Short" + tostring(count_open_shorts-2, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-2, "#"))-    strategy.close("Short" + tostring(count_open_shorts-3, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-3, "#"))-    strategy.close("Short" + tostring(count_open_shorts-4, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-4, "#"))-    strategy.close("Short" + tostring(count_open_shorts-5, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-5, "#"))-    strategy.close("Short" + tostring(count_open_shorts-6, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-6, "#"))-    strategy.close("Short" + tostring(count_open_shorts-7, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-7, "#"))-    strategy.close("Short" + tostring(count_open_shorts-8, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-8, "#"))-    strategy.close("Short" + tostring(count_open_shorts-9, "#"))+    strategy.close("Short" + str.tostring(count_open_shorts-9, "#"))

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: 17 before, 9 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.

⋯// © FX_minds-//@version=5+//@version=6strategy("ETF trader", overlay=true, pyramiding=100, default_qty_type=strategy.percent_of_equity, default_qty_value=100)⋯

Settings

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

SettingDefaultType and rangeFeeds
HH LL lookback20int (written input.integer)long_condition short_condition
ATR period14int (written input.integer)SL_distance TP_distance trailing_SL_distance
ATR SL multiplier2floatSL_distance
ATR TP multiplier1floatTP_distance
ATR trailing SL multiplier3.5floattrailing_SL_distance
trailing SL lookback4int (written input.integer)trailing_SL_short trailing_SL_long
max sequel trades1floatentry "Long" + tostring(count_open_longs, "#") exit "SL Long"+ tostring(count_open_longs, "#") entry "Short" + tostring(count_open_shorts, "#") exit "SL Short" + tostring(count_open_shorts, "#") line 54 line 58
trade long ?trueboolentry "Long" + tostring(count_open_longs, "#") exit "SL Long"+ tostring(count_open_longs, "#") line 54
trade short ?falseboolentry "Short" + tostring(count_open_shorts, "#") exit "SL Short" + tostring(count_open_shorts, "#") line 58

What it calculates

  • ATR (atr, ta.atr in v5)ATR period (14)SL_distance · line 38
  • ATR (atr, ta.atr in v5)ATR period (14)TP_distance · line 39
  • ATR (atr, ta.atr in v5)ATR period (14)trailing_SL_distance · line 40
  • Lowest (lowest, ta.lowest in v5)close, trailing SL lookback (4)trailing_SL_short · line 43
  • Highest (highest, ta.highest in v5)close, trailing SL lookback (4)trailing_SL_long · line 44
  • Crossover (crossover, ta.crossover in v5)high, trailing_SL_short[1]trailing_SL_short_signal · line 45
  • Crossunder (crossunder, ta.crossunder in v5)low, trailing_SL_long[1]trailing_SL_long_signal · line 46

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.

high · low · closehigh · low · closeprice dataATR_periodeATR periodsetting · 14ATR_SL_multiplierATR SL multipliersetting · 2ATR_TP_multiplierATR TP multipliersetting · 1trailing_SL_ATR_multiplierATR trailing SL multipl…setting · 3.5closecloseprice datalookback_trailing_SLtrailing SL lookbacksetting · 4highhighprice datalowlowprice datalookbackHH LL lookbacksetting · 20max_sequel_tradesmax sequel tradessetting · 1SL_distanceATR→ SL_distanceTP_distanceATR→ TP_distancetrailing_SL_distanceATR→ trailing_SL_distancetrailing_SL_shortLowest→ trailing_SL_shorttrailing_SL_longHighest→ trailing_SL_longtrailing_SL_short_signalCrossover→ trailing_SL_short_signaltrailing_SL_long_signalCrossunder→ trailing_SL_long_signalcount_open_longscount_open_longsvaluecount_open_shortscount_open_shortsvalueentryprice_longentryprice_longvalueentryprice_shortentryprice_shortvalueSL_longSL_longvalueSL_shortSL_shortvaluelong_conditionlong_conditionconditionshort_conditionshort_conditionconditionentry:"Long" + tostring(count_open_longs, "#")Open "Long" + tostring(…strategy.entryexit:"SL Long"+ tostring(count_open_longs, "#")exit "SL Long"+ tostrin…strategy.exitentry:"Short" + tostring(count_open_shorts, "#")Open "Short" + tostring…strategy.entryexit:"SL Short" + tostring(count_open_shorts, "#")exit "SL Short" + tostr…strategy.exitclose:"Long" + tostring(count_open_longs, "#")Close "Long" + tostring…strategy.closeclose:"Long" + tostring(count_open_longs-1, "#")Close "Long" + tostring…strategy.closeclose:"Long" + tostring(count_open_longs-2, "#")Close "Long" + tostring…strategy.closeclose:"Long" + tostring(count_open_longs-4, "#")Close "Long" + tostring…strategy.closeclose:"Long" + tostring(count_open_longs-5, "#")Close "Long" + tostring…strategy.closeclose:"Long" + tostring(count_open_longs-6, "#")Close "Long" + tostring…strategy.closeclose:"Long" + tostring(count_open_longs-7, "#")Close "Long" + tostring…strategy.closeclose:"Long" + tostring(count_open_longs-8, "#")Close "Long" + tostring…strategy.closeclose:"Long" + tostring(count_open_longs-9, "#")Close "Long" + tostring…strategy.closeclose:"Short" + tostring(count_open_shorts, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-1, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-2, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-3, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-4, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-5, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-6, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-7, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-8, "#")Close "Short" + tostrin…strategy.closeclose:"Short" + tostring(count_open_shorts-9, "#")Close "Short" + tostrin…strategy.closeplot:48plotplotplot:49plotplotplot:50plotplotplot:51plotplotplot:52plotplot

Order rules

OrderFires whenBy defaultLine
Open "Long" + tostring(count_open_longs, "#") long(long_condition) and (count_open_longs <= max_sequel_trades) and (trade_long == true)On55
Exit "SL Long"+ tostring(count_open_longs, "#") stop(long_condition) and (count_open_longs <= max_sequel_trades) and (trade_long == true)On56
Open "Short" + tostring(count_open_shorts, "#") short(short_condition) and (count_open_shorts <= max_sequel_trades) and (trade_short == true)On59
Exit "SL Short" + tostring(count_open_shorts, "#") stop(short_condition) and (count_open_shorts <= max_sequel_trades) and (trade_short == true)On60
Close "Long" + tostring(count_open_longs, "#")(trailing_SL_long_signal)On65
Close "Long" + tostring(count_open_longs-1, "#")(trailing_SL_long_signal)On66
Close "Long" + tostring(count_open_longs-2, "#")(trailing_SL_long_signal)On67
Close "Long" + tostring(count_open_longs-4, "#")(trailing_SL_long_signal)On68
Close "Long" + tostring(count_open_longs-5, "#")(trailing_SL_long_signal)On69
Close "Long" + tostring(count_open_longs-6, "#")(trailing_SL_long_signal)On70
Close "Long" + tostring(count_open_longs-7, "#")(trailing_SL_long_signal)On71
Close "Long" + tostring(count_open_longs-8, "#")(trailing_SL_long_signal)On72
Close "Long" + tostring(count_open_longs-9, "#")(trailing_SL_long_signal)On73
Close "Short" + tostring(count_open_shorts, "#")(trailing_SL_short_signal)On76
Close "Short" + tostring(count_open_shorts-1, "#")(trailing_SL_short_signal)On77
Close "Short" + tostring(count_open_shorts-2, "#")(trailing_SL_short_signal)On78
Close "Short" + tostring(count_open_shorts-3, "#")(trailing_SL_short_signal)On79
Close "Short" + tostring(count_open_shorts-4, "#")(trailing_SL_short_signal)On80
Close "Short" + tostring(count_open_shorts-5, "#")(trailing_SL_short_signal)On81
Close "Short" + tostring(count_open_shorts-6, "#")(trailing_SL_short_signal)On82
Close "Short" + tostring(count_open_shorts-7, "#")(trailing_SL_short_signal)On83
Close "Short" + tostring(count_open_shorts-8, "#")(trailing_SL_short_signal)On84
Close "Short" + tostring(count_open_shorts-9, "#")(trailing_SL_short_signal)On85

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.

Not measuredAn engine gap, not the scriptThe script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script. The answer comes from the checks on the source alone.
  • 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+78.3%+102.5%1735%1.5932.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+5.8%+5.5%1520%1.2312.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+56.1%+9.8%1127%1.5034.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+1.1%+8.4%1315%1.0416.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−32.7%+16.7%1225%0.7044.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+3.2%+21.5%1527%1.0914.9%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+33.3%+148.3%1644%1.2829.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+27.6%+17.1%1631%2.1820.5%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 market633%−$19,226.60
Sideways market850%$143,749.00
Falling market30%−$46,219.70

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

How bad could the drawdown be?

43.9%

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

0%50%
All 17 trades
SideEntryExitBarsP&L
long21 Feb 2024 52,258.806 Mar 2024 63,724.0014$21,939.20
long16 May 2024 66,206.5024 Jun 2024 60,554.8039−$10,409.30
long16 Jul 2024 64,724.104 Aug 2024 59,789.3019−$8,503.43
long24 Aug 2024 64,037.2027 Aug 2024 58,112.503−$9,532.06
long18 Sep 2024 60,314.002 Feb 2025 96,400.70137$55,939.00
long15 Oct 2024 66,084.002 Feb 2025 96,400.70110$46,994.80
long18 Jan 2025 104,077.002 Feb 2025 96,400.7015−$16,244.10
long23 Apr 2025 93,443.0019 Aug 2025 113,261.00118$38,214.00
long3 Jul 2025 108,850.0019 Aug 2025 113,261.0047$8,505.74
long12 Aug 2025 118,686.0019 Aug 2025 113,261.007−$11,328.60
long16 Sep 2025 115,350.0025 Sep 2025 110,472.009−$9,116.16
long2 Oct 2025 118,595.0010 Oct 2025 113,543.008−$8,794.07
long10 Dec 2025 92,678.8018 Dec 2025 85,128.708−$16,102.80
long5 Mar 2026 72,666.8029 Mar 2026 65,348.5024−$18,285.00
long9 Apr 2026 71,069.903 Jun 2026 65,919.8055−$11,831.90
long15 Jul 2026 65,044.008 Oct 2026 81,599.5085$38,547.00
long22 Sep 2026 86,620.008 Oct 2026 81,599.5016−$11,689.60

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
ETF trader this page—v4 strategy+78.3%1732.7%
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%
Chandelier Exit by Zeal Terminalatr highest lowestv5 indicatorindicator
DC Breakout Strategy - This is simplicity at its finest. by Robrecht99highest lowest atrv5 strategy+10.8%578.3%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 37 msWith a workaround 1,000 bars in 44 msNot measured
PineTSNo v5 and v6 only—Not measured

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.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © FX_minds//@version=4strategy("ETF trader", overlay=true, pyramiding=100, default_qty_type=strategy.percent_of_equity, default_qty_value=100)//------------------------------ get user inputlookback                   = input(title="HH LL lookback", type=input.integer, defval=20)ATR_periode                = input(title="ATR period", type=input.integer, defval=14)ATR_SL_multiplier          = input(title="ATR SL multiplier", type=input.float, defval=2)ATR_TP_multiplier          = input(title="ATR TP multiplier", type=input.float, defval=1)trailing_SL_ATR_multiplier = input(title="ATR trailing SL multiplier", type=input.float, defval=3.5)lookback_trailing_SL       = input(title="trailing SL lookback", type=input.integer, defval=4)max_sequel_trades          = input(title="max sequel trades", type=input.float, defval=1)trade_long                 = input(title= "trade long ?", type=input.bool, defval=true)trade_short                = input(title= "trade short ?", type=input.bool, defval=false)//------------------------------ determine entry conditionslong_condition   = barstate.isconfirmed and crossover(high, highest(high, lookback)[1])short_condition  = barstate.isconfirmed and crossunder(low, lowest(low, lookback)[1])//------------------------------ count open long tradescount_open_longs = 0count_open_longs := nz(count_open_longs[1])if (long_condition)     count_open_longs := count_open_longs +1    //label.new(bar_index, low, tostring(count_open_longs, "#"), xloc.bar_index, yloc.belowbar, color.green, label.style_none, color.green, size.large)if (short_condition)    count_open_longs := 0//------------------------------ count open short tradescount_open_shorts = 0count_open_shorts := nz(count_open_shorts[1])if (short_condition)    count_open_shorts := count_open_shorts +1    //label.new(bar_index, low, tostring(count_open_shorts, "#"), xloc.bar_index, yloc.belowbar, color.red, label.style_none, color.red, size.large)if (long_condition)    count_open_shorts := 0//------------------------------ calculate entrypriceentryprice_long = long_condition ? close : naentryprice_short = short_condition ? close : na//------------------------------ calculate SL & TPSL_distance = atr(ATR_periode) * ATR_SL_multiplierTP_distance  = atr(ATR_periode) * ATR_TP_multipliertrailing_SL_distance = atr(ATR_periode) * trailing_SL_ATR_multiplierSL_long = entryprice_long - SL_distanceSL_short = entryprice_short + SL_distancetrailing_SL_short = lowest(close, lookback_trailing_SL) + trailing_SL_distancetrailing_SL_long  = highest(close, lookback_trailing_SL) - trailing_SL_distancetrailing_SL_short_signal = crossover(high, trailing_SL_short[1])trailing_SL_long_signal = crossunder(low, trailing_SL_long[1])//------------------------------ plot entry price & SL  plot(entryprice_long, style=plot.style_linebr, color=color.white)plot(SL_long, style=plot.style_linebr, color=color.red)plot(SL_short, style=plot.style_linebr, color=color.green)plot(trailing_SL_short, style=plot.style_linebr, color=color.red)plot(trailing_SL_long, style=plot.style_linebr, color=color.green)//------------------------------ submit entry ordersif (long_condition) and (count_open_longs <= max_sequel_trades) and (trade_long == true)    strategy.entry("Long" + tostring(count_open_longs, "#"), strategy.long)    strategy.exit("SL Long"+ tostring(count_open_longs, "#"),      from_entry="Long" + tostring(count_open_longs, "#"), stop=SL_long)if (short_condition) and (count_open_shorts <= max_sequel_trades) and (trade_short == true)    strategy.entry("Short" + tostring(count_open_shorts, "#"), strategy.short)    strategy.exit("SL Short" + tostring(count_open_shorts, "#"),      from_entry="Short" + tostring(count_open_shorts, "#"), stop=SL_short)    //------------------------------ submit exit conditionsif (trailing_SL_long_signal)    strategy.close("Long" + tostring(count_open_longs, "#"))    strategy.close("Long" + tostring(count_open_longs-1, "#"))    strategy.close("Long" + tostring(count_open_longs-2, "#"))    strategy.close("Long" + tostring(count_open_longs-4, "#"))    strategy.close("Long" + tostring(count_open_longs-5, "#"))    strategy.close("Long" + tostring(count_open_longs-6, "#"))    strategy.close("Long" + tostring(count_open_longs-7, "#"))    strategy.close("Long" + tostring(count_open_longs-8, "#"))    strategy.close("Long" + tostring(count_open_longs-9, "#"))    if (trailing_SL_short_signal)    strategy.close("Short" + tostring(count_open_shorts, "#"))    strategy.close("Short" + tostring(count_open_shorts-1, "#"))    strategy.close("Short" + tostring(count_open_shorts-2, "#"))    strategy.close("Short" + tostring(count_open_shorts-3, "#"))    strategy.close("Short" + tostring(count_open_shorts-4, "#"))    strategy.close("Short" + tostring(count_open_shorts-5, "#"))    strategy.close("Short" + tostring(count_open_shorts-6, "#"))    strategy.close("Short" + tostring(count_open_shorts-7, "#"))    strategy.close("Short" + tostring(count_open_shorts-8, "#"))    strategy.close("Short" + tostring(count_open_shorts-9, "#"))