Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Trend Breakout high-low #1

A Pine Script v4 strategy built on Change (t1, 1), SMA (close[0], 300) and EMA or TR (true, 1). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 14 settings; defaults include Trading period 3D, Stop loss 1000 and Trading range 100.

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 Trend Breakout high-low #1 repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 48 of 48 trades.
How did Trend Breakout high-low #1 do on BTCUSDT 1D with default settings?
−6.83%
From 26 Jan 2024 to 21 Oct 2026, over 123 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Trend Breakout high-low #1 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 Trend Breakout high-low #1 use a stop loss?
Yes
strategy.exit sets a stop on line 70, 72, 78, 80.
Does Trend Breakout high-low #1 run in Zeal Terminal?
Yes
It compiles in 30 ms and runs 1,000 bars in 68 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • HIGH
  • LOW
  • Plot
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$93,171$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. The live re-run is not offered here: the script requests BINANCE:BTCUSDT 3D, which this page cannot load in your browser.
Net profit
−6.83%
−$6,830.36
Buy and hold
+102.5%
same period
Closed trades
123
64 won · 59 lost
Profitable
52.0%
of closed trades
Profit factor
0.87
gross profit ÷ gross loss
Max drawdown
11.51%
−$11,645.20

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.

  • Note

    Uses an argument v6 removed

    when = on line 69, 77. 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 change → ta.change, sma → ta.sma, security → request.security, ema → ta.ema, tr → ta.tr.
  • 2 strategy calls use the when = argument (line 69, 77). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Differs

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

  • Line 3: //@version=4 → //@version=5
  • Line 5: input(type = input.time) → input.time()
  • Line 6: input(type = input.time) → input.time()
  • Line 7: input(type = input.session) → input.session()
  • Line 10: range is reserved in v5: renamed range_
  • Line 13: input(type = input.bool) → input.bool()
12 more edits
  • Line 15: input(type = input.bool) → input.bool()
  • Line 16: input(type = input.bool) → input.bool()
  • Line 17: input(type = input.bool) → input.bool()
  • Line 22: change → ta.change
  • Line 28: change → ta.change
  • Line 45: sma → ta.sma
  • Line 46: security → request.security
  • Line 48: sma → ta.sma
  • Line 51: ema → ta.ema
  • Line 51: tr → ta.tr
  • Line 52: ema → ta.ema
  • Line 52: tr → ta.tr
⋯// © zxcv55602-//@version=4+//@version=5strategy("Trend #1 - ATR+Breakout high/low", overlay = true,slippage=0,commission_value=0,initial_capital=100000)-date1 = input(title="Start Date", type=input.time, defval=timestamp("2020-01-01T00:00:00"))+date1 = input.time(title="Start Date", defval=timestamp("2020-01-01T00:00:00"))-date2 = input(title="Stop Date", type=input.time, defval=timestamp("2030-01-01T00:00:00"))+date2 = input.time(title="Stop Date", defval=timestamp("2030-01-01T00:00:00"))-t1= input(title ="Trading period",type=input.session,defval="3D",options=["1M","3W","2W","1W","5D","4D","3D","2D","1D","720","480","360","240","180","120","60","30","15","10","5","3","1"] )+t1= input.session(title ="Trading period",defval="3D",options=["1M","3W","2W","1W","5D","4D","3D","2D","1D","720","480","360","240","180","120","60","30","15","10","5","3","1"] )stop_loss=input(1000,"Stop loss", minval=0,step =1)Trange=input(100,"Trading range", step =1)-range=input(100,"Stop range", step =1)+range_=input(100,"Stop range", step =1)atrlen = input(1, "ATR Period")mult_atr = input(1, "ATR mult", step=0.1)-smalong=input(title="SMA switch", type=input.bool, defval=false)+smalong=input.bool(title="SMA switch", defval=false)smainput=input(300,"SMA switch", minval=2,step =1)-longsignal=input(title="Long", type=input.bool, defval=true)+longsignal=input.bool(title="Long", defval=true)-shortsignal=input(title="Short", type=input.bool, defval=true)+shortsignal=input.bool(title="Short", defval=true)-fixedmode=input(title="Fixed mode", type=input.bool, defval=false)+fixedmode=input.bool(title="Fixed mode", defval=false)fixed=input(1,"Fixed mode",step =0.1)⋯var float Y_High = na-if change(time(t1),length=1)!= 0+if ta.change(time(t1),length=1)!= 0    Y_High:=high⋯    Y_Low:=low<nz(Y_Low)?low:Y_Low-con1= change(time(t1),length = 1 )  != 0?1:0+con1= ta.change(time(t1),length = 1 )  != 0?1:0//plot(Y_High[0],"LOW",color.yellow,linewidth = 2)⋯var sma1=0.0-sma=sma(close[0],smainput)+sma=ta.sma(close[0],smainput)-sma1:=security(syminfo.tickerid,t1,sma)+sma1:=request.security(syminfo.tickerid,t1,sma)if smalong==false-    sma1:=sma(close[0],smainput)+    sma1:=ta.sma(close[0],smainput)plot(sma1,color=color.new(color.blue,0),linewidth=1)//-------------------upper_atr = ema(tr(true),atrlen) * mult_atr + close+upper_atr = ta.ema(ta.tr(true),atrlen) * mult_atr + close-lower_atr = close - ema(tr(true),atrlen) * mult_atr+lower_atr = close - ta.ema(ta.tr(true),atrlen) * mult_atrplot(upper_atr, color=color.new(color.white,80),style=plot.style_stepline)⋯plot(lower,"LOW",color.red,linewidth = 1,style=plot.style_stepline)-plot(upper-(((upper-lower)/100)*range),color=color.new(color.green,50), linewidth=1)+plot(upper-(((upper-lower)/100)*range_),color=color.new(color.green,50), linewidth=1)-plot(lower+(((upper-lower)/100)*range),color=color.new(color.red,50), linewidth=1)+plot(lower+(((upper-lower)/100)*range_),color=color.new(color.red,50), linewidth=1)//-----------⋯        if strategy.position_size==0 and upper>sma1 and close>upper-            OP_L_stop:=upper-(((upper-lower)/100)*range)+            OP_L_stop:=upper-(((upper-lower)/100)*range_)            con_op:=1⋯        if strategy.position_size==0 and lower<sma1 and close<lower-            OP_S_stop:=lower+(((upper-lower)/100)*range)+            OP_S_stop:=lower+(((upper-lower)/100)*range_)            con_op:=1⋯

Clean v5

Verified

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

  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
  • Line 14: input() → input.int()
3 more edits
  • Line 18: input() → input.int()
  • Line 69: when = close>upper → if block
  • Line 77: when = close<lower → if block
⋯t1= input.session(title ="Trading period",defval="3D",options=["1M","3W","2W","1W","5D","4D","3D","2D","1D","720","480","360","240","180","120","60","30","15","10","5","3","1"] )-stop_loss=input(1000,"Stop loss", minval=0,step =1)+stop_loss=input.int(1000,"Stop loss", minval=0,step =1)-Trange=input(100,"Trading range", step =1)+Trange=input.int(100,"Trading range", step =1)-range_=input(100,"Stop range", step =1)+range_=input.int(100,"Stop range", step =1)-atrlen = input(1, "ATR Period")+atrlen = input.int(1, "ATR Period")-mult_atr = input(1, "ATR mult", step=0.1)+mult_atr = input.int(1, "ATR mult", step=0.1)smalong=input.bool(title="SMA switch", defval=false)-smainput=input(300,"SMA switch", minval=2,step =1)+smainput=input.int(300,"SMA switch", minval=2,step =1)longsignal=input.bool(title="Long", defval=true)⋯fixedmode=input.bool(title="Fixed mode", defval=false)-fixed=input(1,"Fixed mode",step =0.1)+fixed=input.int(1,"Fixed mode",step =0.1)//-----------⋯            con_op:=1-            strategy.entry("OP_L",strategy.long,when=close>upper,qty=fixedmode==true?fixed:(stop_loss/(close-OP_L_stop)),limit=upper_atr)+            if close>upper+                strategy.entry("OP_L",strategy.long,qty=fixedmode==true?fixed:(stop_loss/(close-OP_L_stop)),limit=upper_atr)            strategy.exit("OP_L",stop=OP_L_stop,comment="sell_L",limit=upper_atr)⋯            con_op:=1-            strategy.entry("OP_S",strategy.short,when=close<lower,qty=fixedmode==true?fixed:(stop_loss/(OP_S_stop-close)),limit=lower_atr)+            if close<lower+                strategy.entry("OP_S",strategy.short,qty=fixedmode==true?fixed:(stop_loss/(OP_S_stop-close)),limit=lower_atr)            strategy.exit("OP_S",stop=OP_S_stop,comment="sell_S",limit=lower_atr)⋯

Does it run in Pine Script v6?

No

Same 66 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. The v6 version matches the upgraded v5 version, but the upgrade from the original already changed the results, so it is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © zxcv55602-//@version=5+//@version=6strategy("Trend #1 - ATR+Breakout high/low", overlay = true,slippage=0,commission_value=0,initial_capital=100000)⋯

Settings

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

SettingDefaultType and rangeFeeds
Start Datetimestamp("2020-01-01T00:00:00")timeline 64
Stop Datetimestamp("2030-01-01T00:00:00")timeline 64
Trading period3Dsession · options ["1M","3W","2W","1W","5D","4D","3D","2D","1D","720","480","360","240","180","120","60","30","15","10","5","3","1"]con1 sma1 line 22
Stop loss1000int · min 0 · step 1entry OP_L entry OP_S
Trading range100int · step 1upper lower
Stop range100int · step 1OP_L_stop OP_S_stop plot
ATR Period1intupper_atr lower_atr
ATR mult1int · step 0.1upper_atr lower_atr
SMA switchfalseboolline 47
SMA switch300int · min 2 · step 1sma1 sma
Longtrueboolline 65
Shorttrueboolline 73
Fixed modefalseboolentry OP_L entry OP_S
Fixed mode1int · step 0.1entry OP_L entry OP_S

What it calculates

  • Change (change, ta.change in v5)time(t1), length = 1con1 · line 28
  • SMA (sma, ta.sma in v5)close[0], SMA switch (300)sma1 · line 46
  • SMA (sma, ta.sma in v5)close[0], SMA switch (300)sma · line 45
  • EMA / TR (ema, ta.ema in v5)tr(true), ATR Period (1)upper_atr · line 51
  • EMA / TR (ema, ta.ema in v5)tr(true), ATR Period (1)lower_atr · line 52

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.

t1Trading periodsetting · 3Dclosecloseprice datasmainputSMA switchsetting · 300atrlenATR Periodsetting · 1mult_atrATR multsetting · 1lowlowprice datahighhighprice dataTrangeTrading rangesetting · 100rangeStop rangesetting · 100con1Change→ con1sma1SMA→ sma1smaSMA→ smaupper_atrEMA / TR→ upper_atrlower_atrEMA / TR→ lower_atrY_LowY_LowvalueY_HighY_Highvalueupper, lowerupper · lower2 valuescentral_linecentral_linevalueOP_L_stop, OP_S_stopOP_L_stop · OP_S_stop2 valuesentry:OP_LOpen OP_Lstrategy.entryexit:OP_Lexit OP_Lstrategy.exitentry:OP_SOpen OP_Sstrategy.entryexit:OP_Sexit OP_Sstrategy.exitplot:49plotplotplot:53plotplotplot:54plotplotplot:56HIGHplotplot:57LOWplotplot:58plotplotplot:59plotplot

Order rules

OrderFires whenBy defaultLine
Open OP_L longclose>upperOn69
Exit OP_L stop and limitstrategy.position_size==0 and upper>sma1 and close>upperOn70
Exit OP_L stop and limitstrategy.position_size>0On72
Open OP_S shortclose<lowerOn77
Exit OP_S stop and limitstrategy.position_size==0 and lower<sma1 and close<lowerOn78
Exit OP_S stop and limitstrategy.position_size<0On80

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.

48/48trades 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 data1 security call(s), none with lookahead on.
  • 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−6.8%+102.5%12352%0.8711.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.9%+5.5%13259%1.047.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−8.1%+9.8%11054%0.8110.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+7.0%+8.4%11960%1.178.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−2.3%+16.7%11557%0.958.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+1.7%+21.5%11756%1.047.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−6.7%+148.3%12453%0.8816.8%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.8%+17.1%12656%1.019.6%8 May 2026 – 21 Oct 2026

Higher-timeframe data for request.security(): BINANCE:BTCUSDT 3D (Binance BTCUSDT 3d), fetched from Binance's public market data for each market.

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market3951%−$6,072.50
Sideways market5052%−$502.16
Falling market3453%−$255.70

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

How bad could the drawdown be?

18.0%

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

0%21%
All 123 trades
SideEntryExitBarsP&L
long21 Nov 2024 94,286.6021 Nov 2024 97,618.500$847.92
long22 Nov 2024 98,317.1026 Nov 2024 91,500.004−$1,000.00
long28 Nov 2024 95,863.1029 Nov 2024 97,568.001$336.13
long30 Nov 2024 97,460.001 Dec 2024 97,779.901$113.45
long5 Dec 2024 98,587.305 Dec 2024 102,999.000$880.82
long9 Dec 2024 101,110.009 Dec 2024 98,844.000−$1,000.00
long12 Dec 2024 101,125.0015 Dec 2024 103,461.003$340.05
long16 Dec 2024 104,464.0018 Dec 2024 100,609.002−$1,000.00
long25 Dec 2024 98,663.6030 Dec 2024 92,520.005−$1,000.00
long3 Jan 2025 96,984.806 Jan 2025 99,923.703$717.36
long7 Jan 2025 102,236.007 Jan 2025 97,276.800−$1,000.00
long15 Jan 2025 96,560.9015 Jan 2025 99,585.600$414.12
long16 Jan 2025 100,497.0017 Jan 2025 103,519.001$491.21
long18 Jan 2025 104,077.0020 Jan 2025 108,102.002$596.96
long11 Feb 2025 97,430.8012 Feb 2025 94,713.001−$1,000.00
long21 Feb 2025 98,305.0021 Feb 2025 95,030.000−$1,000.00
long2 Mar 2025 86,064.502 Mar 2025 88,797.800$350.14
long3 Mar 2025 94,270.004 Mar 2025 83,824.801−$1,000.00
long6 Mar 2025 90,606.009 Mar 2025 81,500.003−$1,000.00
long13 Mar 2025 83,680.1019 Mar 2025 85,602.106$271.69
long20 Mar 2025 86,845.9023 Mar 2025 84,754.703−$366.17
long24 Mar 2025 86,082.5024 Mar 2025 88,402.400$944.04
long25 Mar 2025 87,498.2028 Mar 2025 83,809.803−$1,000.00
long2 Apr 2025 85,158.402 Apr 2025 88,305.100$811.04
long10 Apr 2025 82,615.2011 Apr 2025 83,896.101$200.92
long12 Apr 2025 83,423.8019 Apr 2025 85,302.807$378.87
long22 Apr 2025 87,516.2022 Apr 2025 90,837.500$931.18
long23 Apr 2025 93,443.0028 Apr 2025 95,515.705$249.78
long2 May 2025 96,489.906 May 2025 96,418.604−$19.92
long7 May 2025 96,834.008 May 2025 98,977.901$645.76
long9 May 2025 103,262.0012 May 2025 105,745.003$332.13
long19 May 2025 106,454.0019 May 2025 102,613.000−$1,000.00
long22 May 2025 109,644.0030 May 2025 104,185.008−$1,000.00
long2 Jun 2025 105,643.005 Jun 2025 103,069.003−$1,000.00
long8 Jun 2025 105,552.009 Jun 2025 107,258.001$382.79
long10 Jun 2025 110,263.0013 Jun 2025 104,964.003−$1,000.00
long17 Jun 2025 106,795.0017 Jun 2025 104,495.000−$1,000.00
long24 Jun 2025 105,334.0025 Jun 2025 107,751.001$338.81
long26 Jun 2025 107,341.0029 Jun 2025 108,063.003$265.74
long30 Jun 2025 108,357.0030 Jun 2025 106,812.000−$1,000.00
long3 Jul 2025 108,850.006 Jul 2025 108,862.003$3.55
long7 Jul 2025 109,204.007 Jul 2025 107,756.000−$1,000.01
long10 Jul 2025 111,234.0010 Jul 2025 114,909.000$966.05
long11 Jul 2025 116,010.0013 Jul 2025 118,720.002$352.61
long14 Jul 2025 119,087.0014 Jul 2025 121,350.000$1,035.04
long15 Jul 2025 119,841.0015 Jul 2025 117,225.000−$1,000.00
long23 Jul 2025 119,954.0025 Jul 2025 116,515.002−$1,000.00
long28 Jul 2025 119,416.0029 Jul 2025 117,138.001−$1,000.00
long4 Aug 2025 114,209.007 Aug 2025 117,353.003$1,425.48
long8 Aug 2025 117,472.0010 Aug 2025 118,107.002$154.28
long11 Aug 2025 119,294.0011 Aug 2025 122,144.000$951.70
long14 Aug 2025 123,306.0014 Aug 2025 118,207.000−$1,000.00
long23 Aug 2025 116,936.0024 Aug 2025 112,016.001−$1,000.00
long3 Sep 2025 111,240.007 Sep 2025 111,519.004$69.93
long9 Sep 2025 112,065.0010 Sep 2025 114,073.001$1,065.01
long11 Sep 2025 113,960.0015 Sep 2025 116,298.004$732.21
long17 Sep 2025 116,789.0022 Sep 2025 114,384.005−$1,000.00
long25 Sep 2025 113,307.0025 Sep 2025 111,459.000−$1,000.01
long29 Sep 2025 112,164.001 Oct 2025 116,185.002$1,297.19
long2 Oct 2025 118,595.003 Oct 2025 123,272.001$787.56
long4 Oct 2025 122,232.005 Oct 2025 123,681.001$366.53
long6 Oct 2025 123,482.007 Oct 2025 121,510.001−$1,000.01
long13 Oct 2025 114,959.0016 Oct 2025 109,562.003−$1,000.00
long20 Oct 2025 108,643.0023 Oct 2025 110,065.003$612.72
long24 Oct 2025 110,078.0026 Oct 2025 112,917.002$832.01
long27 Oct 2025 114,559.0029 Oct 2025 110,673.002−$1,000.00
long11 Nov 2025 106,011.0012 Nov 2025 101,400.001−$1,000.00
short13 Nov 2025 101,654.0016 Nov 2025 93,308.103$1,427.79
short17 Nov 2025 94,261.4020 Nov 2025 87,182.703$2,738.12
short21 Nov 2025 86,637.2028 Nov 2025 92,980.207−$1,000.00
short2 Dec 2025 86,286.002 Dec 2025 92,000.000−$1,000.00
short6 Dec 2025 89,330.007 Dec 2025 87,854.801$310.57
short15 Dec 2025 88,172.2015 Dec 2025 85,277.100$1,175.70
short16 Dec 2025 86,432.1022 Dec 2025 90,472.406−$1,000.00
short24 Dec 2025 87,486.0029 Dec 2025 87,299.005$60.29
short30 Dec 2025 87,237.1030 Dec 2025 88,088.800−$1,000.00
short19 Jan 2026 93,673.1020 Jan 2026 90,868.101$1,426.57
short21 Jan 2026 88,427.7025 Jan 2026 88,430.004−$0.45
short26 Jan 2026 86,670.4028 Jan 2026 89,957.402−$1,000.00
short30 Jan 2026 84,650.2031 Jan 2026 80,642.701$673.53
short1 Feb 2026 78,741.103 Feb 2026 73,982.602$793.79
short6 Feb 2026 62,909.9011 Feb 2026 66,113.705−$227.84
short12 Feb 2026 67,082.5014 Feb 2026 70,527.602−$1,000.00
short19 Feb 2026 66,461.0023 Feb 2026 66,588.404−$45.82
short24 Feb 2026 64,656.0025 Feb 2026 68,245.001−$1,000.00
short28 Feb 2026 65,872.102 Mar 2026 68,860.002−$1,000.00
short7 Mar 2026 68,114.008 Mar 2026 65,627.101$456.80
short9 Mar 2026 65,971.209 Mar 2026 68,551.000−$1,000.00
short19 Mar 2026 71,246.6026 Mar 2026 69,718.407$321.47
short27 Mar 2026 68,820.3029 Mar 2026 65,020.202$1,185.40
short3 Apr 2026 66,902.006 Apr 2026 69,310.003−$1,000.00
short13 Apr 2026 70,741.6013 Apr 2026 73,790.000−$999.81
short20 Apr 2026 73,801.8022 Apr 2026 77,420.102−$1,000.00
short29 Apr 2026 76,342.804 May 2026 79,485.705−$1,000.00
short8 May 2026 80,006.0022 May 2026 76,135.0014$1,361.11
short23 May 2026 75,539.5026 May 2026 76,330.703−$297.40
short27 May 2026 75,930.001 Jun 2026 72,798.705$1,585.05
short2 Jun 2026 71,408.902 Jun 2026 68,003.600$1,187.86
short3 Jun 2026 66,760.805 Jun 2026 60,505.202$853.29
short6 Jun 2026 61,056.509 Jun 2026 61,294.003−$64.06
short10 Jun 2026 61,730.0012 Jun 2026 64,200.002−$1,000.00
short18 Jun 2026 64,509.4024 Jun 2026 60,397.206$1,656.41
short25 Jun 2026 61,078.0028 Jun 2026 58,943.003$667.74
short29 Jun 2026 59,577.0030 Jun 2026 58,379.701$877.73
short1 Jul 2026 58,624.701 Jul 2026 60,780.600−$1,000.00
short9 Jul 2026 62,290.0010 Jul 2026 64,314.001−$1,000.00
short13 Jul 2026 63,780.0013 Jul 2026 63,130.700$896.66
short14 Jul 2026 62,334.5014 Jul 2026 64,290.100−$1,000.00
short17 Jul 2026 63,830.2017 Jul 2026 62,581.400$705.61
short24 Jul 2026 65,099.0027 Jul 2026 64,116.803$598.55
short28 Jul 2026 63,755.9031 Jul 2026 63,207.303$301.20
short1 Aug 2026 62,887.903 Aug 2026 62,580.302$134.41
short11 Aug 2026 63,970.0016 Aug 2026 62,818.005$765.72
short17 Aug 2026 62,900.0017 Aug 2026 63,188.000−$1,000.00
long25 Aug 2026 78,992.8027 Aug 2026 80,642.802$478.67
long28 Aug 2026 80,249.6028 Aug 2026 77,632.600−$1,000.00
long4 Sep 2026 81,270.4011 Sep 2026 76,264.007−$1,000.00
long15 Sep 2026 78,189.2015 Sep 2026 76,500.000−$999.99
long19 Sep 2026 80,883.9021 Sep 2026 82,549.302$341.01
long22 Sep 2026 86,620.0027 Sep 2026 85,108.705−$232.73
long5 Oct 2026 86,530.007 Oct 2026 84,456.002−$1,000.00
long12 Oct 2026 83,773.1012 Oct 2026 82,545.800−$1,000.00
long19 Oct 2026 82,116.0020 Oct 2026 83,347.601$950.02

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
Trend Breakout high-low #1 this page—v4 strategy−6.8%12311.5%
Scalping Trading System bot Crypto and Stocks by exlux99sma ema trv5 strategy+6.5%51.0%
Daily Investments Index Scalp by dailycryptoinvestmentssma ema trv5 strategy−6.9%4230.1%
MACD Long Strat by TheGrindTodayema smav4 strategy+24.0%7920.1%
Stock trending strategy by exlux99ema smav4 strategy+35.3%2114.7%
4-Hour Stochastic EMA Trend by slymnturkogluema smav4 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 30 msWith a workaround 1,000 bars in 68 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/// © zxcv55602//@version=4strategy("Trend #1 - ATR+Breakout high/low", overlay = true,slippage=0,commission_value=0,initial_capital=100000)date1 = input(title="Start Date", type=input.time, defval=timestamp("2020-01-01T00:00:00"))date2 = input(title="Stop Date", type=input.time, defval=timestamp("2030-01-01T00:00:00"))t1= input(title ="Trading period",type=input.session,defval="3D",options=["1M","3W","2W","1W","5D","4D","3D","2D","1D","720","480","360","240","180","120","60","30","15","10","5","3","1"] )stop_loss=input(1000,"Stop loss", minval=0,step =1)Trange=input(100,"Trading range", step =1)range=input(100,"Stop range", step =1)atrlen = input(1, "ATR Period")mult_atr = input(1, "ATR mult", step=0.1)smalong=input(title="SMA switch", type=input.bool, defval=false)smainput=input(300,"SMA switch", minval=2,step =1)longsignal=input(title="Long", type=input.bool, defval=true)shortsignal=input(title="Short", type=input.bool, defval=true)fixedmode=input(title="Fixed mode", type=input.bool, defval=false)fixed=input(1,"Fixed mode",step =0.1)//-----------var float Y_Low = navar float Y_High = naif change(time(t1),length=1)!= 0    Y_High:=high    Y_Low:= lowelse    Y_High:=high>nz(Y_High)?high:Y_High    Y_Low:=low<nz(Y_Low)?low:Y_Lowcon1= change(time(t1),length = 1 )  != 0?1:0//plot(Y_High[0],"LOW",color.yellow,linewidth = 2)//plot(Y_Low[0],"LOW",color.white,linewidth = 2)//-----------var upper=0.0var lower=0.0var con_op=0.0var central_line=0.0if con1==1    upper:=Y_High[1]-(((Y_High[1]-Y_Low[1])/100)*(100-Trange)/2)    lower:=Y_Low[1]+(((Y_High[1]-Y_Low[1])/100)*(100-Trange)/2)    con_op:=0    central_line:=(Y_High[1]+Y_Low[1])/2//----------- //plotarrow(con1==1?con1:na,colorup=color.white,colordown=color.white)//-----------var sma1=0.0sma=sma(close[0],smainput)sma1:=security(syminfo.tickerid,t1,sma)if smalong==false    sma1:=sma(close[0],smainput)plot(sma1,color=color.new(color.blue,0),linewidth=1)//------------------upper_atr = ema(tr(true),atrlen) * mult_atr + closelower_atr = close - ema(tr(true),atrlen) * mult_atrplot(upper_atr, color=color.new(color.white,80),style=plot.style_stepline)plot(lower_atr, color=color.new(color.white,80),style=plot.style_stepline)//------------------plot(upper,"HIGH",color.green,linewidth = 1,style=plot.style_stepline)plot(lower,"LOW",color.red,linewidth = 1,style=plot.style_stepline)plot(upper-(((upper-lower)/100)*range),color=color.new(color.green,50), linewidth=1)plot(lower+(((upper-lower)/100)*range),color=color.new(color.red,50), linewidth=1)//-----------var OP_L_stop=0.0var OP_S_stop=0.0//-----------if time >= date1 and time <= date2 and con_op==0    if longsignal        if strategy.position_size==0 and upper>sma1 and close>upper            OP_L_stop:=upper-(((upper-lower)/100)*range)            con_op:=1            strategy.entry("OP_L",strategy.long,when=close>upper,qty=fixedmode==true?fixed:(stop_loss/(close-OP_L_stop)),limit=upper_atr)            strategy.exit("OP_L",stop=OP_L_stop,comment="sell_L",limit=upper_atr)        if strategy.position_size>0            strategy.exit("OP_L",stop=OP_L_stop,comment="stop_L",limit=upper_atr)    if shortsignal        if strategy.position_size==0 and lower<sma1 and close<lower            OP_S_stop:=lower+(((upper-lower)/100)*range)            con_op:=1            strategy.entry("OP_S",strategy.short,when=close<lower,qty=fixedmode==true?fixed:(stop_loss/(OP_S_stop-close)),limit=lower_atr)            strategy.exit("OP_S",stop=OP_S_stop,comment="sell_S",limit=lower_atr)        if strategy.position_size<0            strategy.exit("OP_S",stop=OP_S_stop,comment="stop_S",limit=lower_atr)