Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Highest High and Lowest Low Channel Strategy

A Pine Script v5 strategy built on Highest (high, 20) and Lowest (low, 20). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 2 settings; defaults include Length 20.

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 Highest High and Lowest Low Channel Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did Highest High and Lowest Low Channel Strategy do on BTCUSDT 1D with default settings?
−3.71%
From 26 Jan 2024 to 21 Oct 2026, over 26 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Highest High and Lowest Low Channel Strategy 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: 26 before, 149 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Highest High and Lowest Low Channel Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Highest High and Lowest Low Channel Strategy run in Zeal Terminal?
Yes
It compiles in 29 ms and runs 1,000 bars in 21 ms, in the browser.

BTCUSDT · 1D · default settings

  • HH
  • LL
  • 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 (2)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$961,010$2,025,273Equity from $1,000,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.
Net profit
−3.71%
−$37,066.90
Buy and hold
+102.5%
same period
Closed trades
26
10 won · 16 lost
Profitable
38.5%
of closed trades
Profit factor
0.72
gross profit ÷ gross loss
Max drawdown
7.88%
−$79,063.10

One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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 stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    1 setting has no label

    In the settings dialog length (line 5) shows an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

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

SettingDefaultType and rangeFeeds
Length (no label in the script)20inthh ll
Trade reversefalsebooliff_2 possig

What it calculates

  • Highesthigh, Length (20)hh · line 7
  • Lowestlow, Length (20)ll · line 8

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.

highhighprice datalengthLengthsetting · 20lowlowprice dataclosecloseprice datahhHighest→ hhllLowest→ llposposvalueiff_1iff_1valueiff_2iff_2valuepossigpossigvalueentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entrybarcolor:18barcolorbarcolorplot:19HHplotplot:20LLplot

Order rules

OrderFires whenBy defaultLine
Open Long longpossig == 1On15
Open Short shortpossig == -1On17

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.

6/6trades 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 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−3.7%+102.5%2638%0.727.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.9%+5.5%1932%1.331.5%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.1%+9.8%1850%1.280.2%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%2133%1.090.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%2232%0.790.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%2040%1.710.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%2030%1.160.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%2635%0.610.0%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 market729%−$32,761.00
Sideways market1540%−$8,525.83
Falling market450%$4,219.93

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

How bad could the drawdown be?

9.2%

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

0%11%
All 26 trades
SideEntryExitBarsP&L
long27 Feb 2024 54,476.502 May 2024 58,365.0065$3,888.49
short2 May 2024 58,365.0016 May 2024 66,206.5014−$7,841.54
long16 May 2024 66,206.5015 Jun 2024 66,044.0030−$162.52
short15 Jun 2024 66,044.0016 Jul 2024 64,724.1031$1,319.93
long16 Jul 2024 64,724.105 Aug 2024 58,161.0020−$6,563.06
short5 Aug 2024 58,161.0024 Aug 2024 64,037.2019−$5,876.24
long24 Aug 2024 64,037.207 Sep 2024 53,963.0014−$10,074.30
short7 Sep 2024 53,963.0019 Sep 2024 61,760.0012−$7,797.01
long19 Sep 2024 61,760.0025 Feb 2025 91,552.90159$29,792.90
short25 Feb 2025 91,552.9023 Apr 2025 93,443.0057−$1,890.11
long23 Apr 2025 93,443.006 Jun 2025 101,509.0044$8,065.70
short6 Jun 2025 101,509.0010 Jul 2025 111,234.0034−$9,725.31
long10 Jul 2025 111,234.002 Aug 2025 113,298.0023$2,063.92
short2 Aug 2025 113,298.0014 Aug 2025 123,306.0012−$10,008.50
long14 Aug 2025 123,306.0026 Aug 2025 110,112.0012−$13,194.50
short26 Aug 2025 110,112.0017 Sep 2025 116,789.0022−$6,676.98
long17 Sep 2025 116,789.0026 Sep 2025 108,994.009−$7,794.47
short26 Sep 2025 108,994.002 Oct 2025 118,595.006−$9,600.50
long2 Oct 2025 118,595.005 Nov 2025 101,497.0034−$17,097.80
short5 Nov 2025 101,497.005 Jan 2026 91,529.7061$9,967.49
long5 Jan 2026 91,529.7026 Jan 2026 86,670.4021−$4,859.38
short26 Jan 2026 86,670.405 Mar 2026 72,666.8038$14,003.60
long5 Mar 2026 72,666.8023 May 2026 75,539.5079$2,872.73
short23 May 2026 75,539.5015 Jul 2026 65,044.0053$10,495.50
long15 Jul 2026 65,044.0016 Sep 2026 75,644.5063$10,600.50
short16 Sep 2026 75,644.5022 Sep 2026 86,620.006−$10,975.50

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
Highest High and Lowest Low Channel Strategy this page—v5 strategy−3.7%267.9%
Alex Days HiLo Rajib by 14rajibhighest lowestv4 strategyNo trades on this market
Donchian Strat EXMO by pskoroplashighest lowestv4 strategy+12.1%2268.0%
Average Highest High and Lowest Low Swinger Strategy by exlux99lowest highestv4 strategy+6.4%2049.6%
Donchian Channels System [racer8] by racer8highest lowestv4 strategy−3.2%3643.6%
eswaran ab by ESWARMONK2515lowest highestv4 strategy+8.4%1339.6%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 2 settings use the untyped input() (line 5, 6). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
  • Line 6: input() → input.bool()
⋯strategy('Highest High and Lowest Low Channel Strategy', overlay=true)-length = input(20)+length = input.int(20)-reverse = input(false, title='Trade reverse')+reverse = input.bool(false, title='Trade reverse')hh = ta.highest(high, length)⋯

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: 26 before, 149 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.

⋯// © ceyhun-//@version=5+//@version=6strategy('Highest High and Lowest Low Channel Strategy', overlay=true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 29 msYes 1,000 bars in 21 msNot measured
PineTSNot testedNot testedNot measured

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

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/// © ceyhun//@version=5strategy('Highest High and Lowest Low Channel Strategy', overlay=true)length = input(20)reverse = input(false, title='Trade reverse')hh = ta.highest(high, length)ll = ta.lowest(low, length)pos = 0.0iff_1 = close < ll[1] ? -1 : nz(pos[1], 0)pos := close > hh[1] ? 1 : iff_1iff_2 = reverse and pos == -1 ? 1 : pospossig = reverse and pos == 1 ? -1 : iff_2if possig == 1    strategy.entry('Long', strategy.long)if possig == -1    strategy.entry('Short', strategy.short)barcolor(possig == -1 ? color.red : possig == 1 ? color.green : color.blue)plot(hh[1], color=color.new(color.green, 0), title='HH', linewidth=2)plot(ll[1], color=color.new(color.red, 0), title='LL', linewidth=2)