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
- 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
DiffersTrades 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
VerifiedSame 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Start Date | timestamp("2020-01-01T00:00:00") | time | line 64 |
| Stop Date | timestamp("2030-01-01T00:00:00") | time | line 64 |
| Trading period | 3D | session · 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 loss | 1000 | int · min 0 · step 1 | entry OP_L entry OP_S |
| Trading range | 100 | int · step 1 | upper lower |
| Stop range | 100 | int · step 1 | OP_L_stop OP_S_stop plot |
| ATR Period | 1 | int | upper_atr lower_atr |
| ATR mult | 1 | int · step 0.1 | upper_atr lower_atr |
| SMA switch | false | bool | line 47 |
| SMA switch | 300 | int · min 2 · step 1 | sma1 sma |
| Long | true | bool | line 65 |
| Short | true | bool | line 73 |
| Fixed mode | false | bool | entry OP_L entry OP_S |
| Fixed mode | 1 | int · step 0.1 | entry OP_L entry OP_S |
What it calculates
- Change (
change,ta.changein v5)time(t1), length = 1con1 · line 28 - SMA (
sma,ta.smain v5)close[0], SMA switch (300)sma1 · line 46 - SMA (
sma,ta.smain v5)close[0], SMA switch (300)sma · line 45 - EMA / TR (
ema,ta.emain v5)tr(true), ATR Period (1)upper_atr · line 51 - EMA / TR (
ema,ta.emain 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open OP_L long | close>upper | On | 69 |
| Exit OP_L stop and limit | strategy.position_size==0 and upper>sma1 and close>upper | On | 70 |
| Exit OP_L stop and limit | strategy.position_size>0 | On | 72 |
| Open OP_S short | close<lower | On | 77 |
| Exit OP_S stop and limit | strategy.position_size==0 and lower<sma1 and close<lower | On | 78 |
| Exit OP_S stop and limit | strategy.position_size<0 | On | 80 |
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 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −6.8% | +102.5% | 123 | 52% | 0.87 | 11.5% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +1.9% | +5.5% | 132 | 59% | 1.04 | 7.6% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −8.1% | +9.8% | 110 | 54% | 0.81 | 10.5% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +7.0% | +8.4% | 119 | 60% | 1.17 | 8.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −2.3% | +16.7% | 115 | 57% | 0.95 | 8.3% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +1.7% | +21.5% | 117 | 56% | 1.04 | 7.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −6.7% | +148.3% | 124 | 53% | 0.88 | 16.8% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.8% | +17.1% | 126 | 56% | 1.01 | 9.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 39 | 51% | −$6,072.50 |
| Sideways market | 50 | 52% | −$502.16 |
| Falling market | 34 | 53% | −$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.
All 123 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 21 Nov 2024 94,286.60 | 21 Nov 2024 97,618.50 | 0 | $847.92 |
| long | 22 Nov 2024 98,317.10 | 26 Nov 2024 91,500.00 | 4 | −$1,000.00 |
| long | 28 Nov 2024 95,863.10 | 29 Nov 2024 97,568.00 | 1 | $336.13 |
| long | 30 Nov 2024 97,460.00 | 1 Dec 2024 97,779.90 | 1 | $113.45 |
| long | 5 Dec 2024 98,587.30 | 5 Dec 2024 102,999.00 | 0 | $880.82 |
| long | 9 Dec 2024 101,110.00 | 9 Dec 2024 98,844.00 | 0 | −$1,000.00 |
| long | 12 Dec 2024 101,125.00 | 15 Dec 2024 103,461.00 | 3 | $340.05 |
| long | 16 Dec 2024 104,464.00 | 18 Dec 2024 100,609.00 | 2 | −$1,000.00 |
| long | 25 Dec 2024 98,663.60 | 30 Dec 2024 92,520.00 | 5 | −$1,000.00 |
| long | 3 Jan 2025 96,984.80 | 6 Jan 2025 99,923.70 | 3 | $717.36 |
| long | 7 Jan 2025 102,236.00 | 7 Jan 2025 97,276.80 | 0 | −$1,000.00 |
| long | 15 Jan 2025 96,560.90 | 15 Jan 2025 99,585.60 | 0 | $414.12 |
| long | 16 Jan 2025 100,497.00 | 17 Jan 2025 103,519.00 | 1 | $491.21 |
| long | 18 Jan 2025 104,077.00 | 20 Jan 2025 108,102.00 | 2 | $596.96 |
| long | 11 Feb 2025 97,430.80 | 12 Feb 2025 94,713.00 | 1 | −$1,000.00 |
| long | 21 Feb 2025 98,305.00 | 21 Feb 2025 95,030.00 | 0 | −$1,000.00 |
| long | 2 Mar 2025 86,064.50 | 2 Mar 2025 88,797.80 | 0 | $350.14 |
| long | 3 Mar 2025 94,270.00 | 4 Mar 2025 83,824.80 | 1 | −$1,000.00 |
| long | 6 Mar 2025 90,606.00 | 9 Mar 2025 81,500.00 | 3 | −$1,000.00 |
| long | 13 Mar 2025 83,680.10 | 19 Mar 2025 85,602.10 | 6 | $271.69 |
| long | 20 Mar 2025 86,845.90 | 23 Mar 2025 84,754.70 | 3 | −$366.17 |
| long | 24 Mar 2025 86,082.50 | 24 Mar 2025 88,402.40 | 0 | $944.04 |
| long | 25 Mar 2025 87,498.20 | 28 Mar 2025 83,809.80 | 3 | −$1,000.00 |
| long | 2 Apr 2025 85,158.40 | 2 Apr 2025 88,305.10 | 0 | $811.04 |
| long | 10 Apr 2025 82,615.20 | 11 Apr 2025 83,896.10 | 1 | $200.92 |
| long | 12 Apr 2025 83,423.80 | 19 Apr 2025 85,302.80 | 7 | $378.87 |
| long | 22 Apr 2025 87,516.20 | 22 Apr 2025 90,837.50 | 0 | $931.18 |
| long | 23 Apr 2025 93,443.00 | 28 Apr 2025 95,515.70 | 5 | $249.78 |
| long | 2 May 2025 96,489.90 | 6 May 2025 96,418.60 | 4 | −$19.92 |
| long | 7 May 2025 96,834.00 | 8 May 2025 98,977.90 | 1 | $645.76 |
| long | 9 May 2025 103,262.00 | 12 May 2025 105,745.00 | 3 | $332.13 |
| long | 19 May 2025 106,454.00 | 19 May 2025 102,613.00 | 0 | −$1,000.00 |
| long | 22 May 2025 109,644.00 | 30 May 2025 104,185.00 | 8 | −$1,000.00 |
| long | 2 Jun 2025 105,643.00 | 5 Jun 2025 103,069.00 | 3 | −$1,000.00 |
| long | 8 Jun 2025 105,552.00 | 9 Jun 2025 107,258.00 | 1 | $382.79 |
| long | 10 Jun 2025 110,263.00 | 13 Jun 2025 104,964.00 | 3 | −$1,000.00 |
| long | 17 Jun 2025 106,795.00 | 17 Jun 2025 104,495.00 | 0 | −$1,000.00 |
| long | 24 Jun 2025 105,334.00 | 25 Jun 2025 107,751.00 | 1 | $338.81 |
| long | 26 Jun 2025 107,341.00 | 29 Jun 2025 108,063.00 | 3 | $265.74 |
| long | 30 Jun 2025 108,357.00 | 30 Jun 2025 106,812.00 | 0 | −$1,000.00 |
| long | 3 Jul 2025 108,850.00 | 6 Jul 2025 108,862.00 | 3 | $3.55 |
| long | 7 Jul 2025 109,204.00 | 7 Jul 2025 107,756.00 | 0 | −$1,000.01 |
| long | 10 Jul 2025 111,234.00 | 10 Jul 2025 114,909.00 | 0 | $966.05 |
| long | 11 Jul 2025 116,010.00 | 13 Jul 2025 118,720.00 | 2 | $352.61 |
| long | 14 Jul 2025 119,087.00 | 14 Jul 2025 121,350.00 | 0 | $1,035.04 |
| long | 15 Jul 2025 119,841.00 | 15 Jul 2025 117,225.00 | 0 | −$1,000.00 |
| long | 23 Jul 2025 119,954.00 | 25 Jul 2025 116,515.00 | 2 | −$1,000.00 |
| long | 28 Jul 2025 119,416.00 | 29 Jul 2025 117,138.00 | 1 | −$1,000.00 |
| long | 4 Aug 2025 114,209.00 | 7 Aug 2025 117,353.00 | 3 | $1,425.48 |
| long | 8 Aug 2025 117,472.00 | 10 Aug 2025 118,107.00 | 2 | $154.28 |
| long | 11 Aug 2025 119,294.00 | 11 Aug 2025 122,144.00 | 0 | $951.70 |
| long | 14 Aug 2025 123,306.00 | 14 Aug 2025 118,207.00 | 0 | −$1,000.00 |
| long | 23 Aug 2025 116,936.00 | 24 Aug 2025 112,016.00 | 1 | −$1,000.00 |
| long | 3 Sep 2025 111,240.00 | 7 Sep 2025 111,519.00 | 4 | $69.93 |
| long | 9 Sep 2025 112,065.00 | 10 Sep 2025 114,073.00 | 1 | $1,065.01 |
| long | 11 Sep 2025 113,960.00 | 15 Sep 2025 116,298.00 | 4 | $732.21 |
| long | 17 Sep 2025 116,789.00 | 22 Sep 2025 114,384.00 | 5 | −$1,000.00 |
| long | 25 Sep 2025 113,307.00 | 25 Sep 2025 111,459.00 | 0 | −$1,000.01 |
| long | 29 Sep 2025 112,164.00 | 1 Oct 2025 116,185.00 | 2 | $1,297.19 |
| long | 2 Oct 2025 118,595.00 | 3 Oct 2025 123,272.00 | 1 | $787.56 |
| long | 4 Oct 2025 122,232.00 | 5 Oct 2025 123,681.00 | 1 | $366.53 |
| long | 6 Oct 2025 123,482.00 | 7 Oct 2025 121,510.00 | 1 | −$1,000.01 |
| long | 13 Oct 2025 114,959.00 | 16 Oct 2025 109,562.00 | 3 | −$1,000.00 |
| long | 20 Oct 2025 108,643.00 | 23 Oct 2025 110,065.00 | 3 | $612.72 |
| long | 24 Oct 2025 110,078.00 | 26 Oct 2025 112,917.00 | 2 | $832.01 |
| long | 27 Oct 2025 114,559.00 | 29 Oct 2025 110,673.00 | 2 | −$1,000.00 |
| long | 11 Nov 2025 106,011.00 | 12 Nov 2025 101,400.00 | 1 | −$1,000.00 |
| short | 13 Nov 2025 101,654.00 | 16 Nov 2025 93,308.10 | 3 | $1,427.79 |
| short | 17 Nov 2025 94,261.40 | 20 Nov 2025 87,182.70 | 3 | $2,738.12 |
| short | 21 Nov 2025 86,637.20 | 28 Nov 2025 92,980.20 | 7 | −$1,000.00 |
| short | 2 Dec 2025 86,286.00 | 2 Dec 2025 92,000.00 | 0 | −$1,000.00 |
| short | 6 Dec 2025 89,330.00 | 7 Dec 2025 87,854.80 | 1 | $310.57 |
| short | 15 Dec 2025 88,172.20 | 15 Dec 2025 85,277.10 | 0 | $1,175.70 |
| short | 16 Dec 2025 86,432.10 | 22 Dec 2025 90,472.40 | 6 | −$1,000.00 |
| short | 24 Dec 2025 87,486.00 | 29 Dec 2025 87,299.00 | 5 | $60.29 |
| short | 30 Dec 2025 87,237.10 | 30 Dec 2025 88,088.80 | 0 | −$1,000.00 |
| short | 19 Jan 2026 93,673.10 | 20 Jan 2026 90,868.10 | 1 | $1,426.57 |
| short | 21 Jan 2026 88,427.70 | 25 Jan 2026 88,430.00 | 4 | −$0.45 |
| short | 26 Jan 2026 86,670.40 | 28 Jan 2026 89,957.40 | 2 | −$1,000.00 |
| short | 30 Jan 2026 84,650.20 | 31 Jan 2026 80,642.70 | 1 | $673.53 |
| short | 1 Feb 2026 78,741.10 | 3 Feb 2026 73,982.60 | 2 | $793.79 |
| short | 6 Feb 2026 62,909.90 | 11 Feb 2026 66,113.70 | 5 | −$227.84 |
| short | 12 Feb 2026 67,082.50 | 14 Feb 2026 70,527.60 | 2 | −$1,000.00 |
| short | 19 Feb 2026 66,461.00 | 23 Feb 2026 66,588.40 | 4 | −$45.82 |
| short | 24 Feb 2026 64,656.00 | 25 Feb 2026 68,245.00 | 1 | −$1,000.00 |
| short | 28 Feb 2026 65,872.10 | 2 Mar 2026 68,860.00 | 2 | −$1,000.00 |
| short | 7 Mar 2026 68,114.00 | 8 Mar 2026 65,627.10 | 1 | $456.80 |
| short | 9 Mar 2026 65,971.20 | 9 Mar 2026 68,551.00 | 0 | −$1,000.00 |
| short | 19 Mar 2026 71,246.60 | 26 Mar 2026 69,718.40 | 7 | $321.47 |
| short | 27 Mar 2026 68,820.30 | 29 Mar 2026 65,020.20 | 2 | $1,185.40 |
| short | 3 Apr 2026 66,902.00 | 6 Apr 2026 69,310.00 | 3 | −$1,000.00 |
| short | 13 Apr 2026 70,741.60 | 13 Apr 2026 73,790.00 | 0 | −$999.81 |
| short | 20 Apr 2026 73,801.80 | 22 Apr 2026 77,420.10 | 2 | −$1,000.00 |
| short | 29 Apr 2026 76,342.80 | 4 May 2026 79,485.70 | 5 | −$1,000.00 |
| short | 8 May 2026 80,006.00 | 22 May 2026 76,135.00 | 14 | $1,361.11 |
| short | 23 May 2026 75,539.50 | 26 May 2026 76,330.70 | 3 | −$297.40 |
| short | 27 May 2026 75,930.00 | 1 Jun 2026 72,798.70 | 5 | $1,585.05 |
| short | 2 Jun 2026 71,408.90 | 2 Jun 2026 68,003.60 | 0 | $1,187.86 |
| short | 3 Jun 2026 66,760.80 | 5 Jun 2026 60,505.20 | 2 | $853.29 |
| short | 6 Jun 2026 61,056.50 | 9 Jun 2026 61,294.00 | 3 | −$64.06 |
| short | 10 Jun 2026 61,730.00 | 12 Jun 2026 64,200.00 | 2 | −$1,000.00 |
| short | 18 Jun 2026 64,509.40 | 24 Jun 2026 60,397.20 | 6 | $1,656.41 |
| short | 25 Jun 2026 61,078.00 | 28 Jun 2026 58,943.00 | 3 | $667.74 |
| short | 29 Jun 2026 59,577.00 | 30 Jun 2026 58,379.70 | 1 | $877.73 |
| short | 1 Jul 2026 58,624.70 | 1 Jul 2026 60,780.60 | 0 | −$1,000.00 |
| short | 9 Jul 2026 62,290.00 | 10 Jul 2026 64,314.00 | 1 | −$1,000.00 |
| short | 13 Jul 2026 63,780.00 | 13 Jul 2026 63,130.70 | 0 | $896.66 |
| short | 14 Jul 2026 62,334.50 | 14 Jul 2026 64,290.10 | 0 | −$1,000.00 |
| short | 17 Jul 2026 63,830.20 | 17 Jul 2026 62,581.40 | 0 | $705.61 |
| short | 24 Jul 2026 65,099.00 | 27 Jul 2026 64,116.80 | 3 | $598.55 |
| short | 28 Jul 2026 63,755.90 | 31 Jul 2026 63,207.30 | 3 | $301.20 |
| short | 1 Aug 2026 62,887.90 | 3 Aug 2026 62,580.30 | 2 | $134.41 |
| short | 11 Aug 2026 63,970.00 | 16 Aug 2026 62,818.00 | 5 | $765.72 |
| short | 17 Aug 2026 62,900.00 | 17 Aug 2026 63,188.00 | 0 | −$1,000.00 |
| long | 25 Aug 2026 78,992.80 | 27 Aug 2026 80,642.80 | 2 | $478.67 |
| long | 28 Aug 2026 80,249.60 | 28 Aug 2026 77,632.60 | 0 | −$1,000.00 |
| long | 4 Sep 2026 81,270.40 | 11 Sep 2026 76,264.00 | 7 | −$1,000.00 |
| long | 15 Sep 2026 78,189.20 | 15 Sep 2026 76,500.00 | 0 | −$999.99 |
| long | 19 Sep 2026 80,883.90 | 21 Sep 2026 82,549.30 | 2 | $341.01 |
| long | 22 Sep 2026 86,620.00 | 27 Sep 2026 85,108.70 | 5 | −$232.73 |
| long | 5 Oct 2026 86,530.00 | 7 Oct 2026 84,456.00 | 2 | −$1,000.00 |
| long | 12 Oct 2026 83,773.10 | 12 Oct 2026 82,545.80 | 0 | −$1,000.00 |
| long | 19 Oct 2026 82,116.00 | 20 Oct 2026 83,347.60 | 1 | $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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Trend Breakout high-low #1 this page | — | v4 strategy | −6.8% | 123 | 11.5% |
| Scalping Trading System bot Crypto and Stocks by exlux99 | sma ema tr | v5 strategy | +6.5% | 5 | 1.0% |
| Daily Investments Index Scalp by dailycryptoinvestments | sma ema tr | v5 strategy | −6.9% | 42 | 30.1% |
| MACD Long Strat by TheGrindToday | ema sma | v4 strategy | +24.0% | 79 | 20.1% |
| Stock trending strategy by exlux99 | ema sma | v4 strategy | +35.3% | 21 | 14.7% |
| 4-Hour Stochastic EMA Trend by slymnturkoglu | ema sma | v4 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 30 ms | With a workaround 1,000 bars in 68 ms | Not measured |
| PineTS | No 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)