Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Hi-Lo Channel Strategy

A Pine Script v4 strategy built on SMA (ha_h, 5). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 3 settings; defaults include High-Based MA 5 and Low-Based MA 5.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Hi-Lo Channel Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 10 of 10 trades.
How did Hi-Lo Channel Strategy do on BTCUSDT 1D with default settings?
+19.99%
From 26 Jan 2024 to 21 Oct 2026, over 41 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Hi-Lo Channel Strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does Hi-Lo Channel Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Hi-Lo Channel Strategy run in Zeal Terminal?
Yes
It compiles in 15 ms and runs 1,000 bars in 50 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$600$1,013Equity from $500
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Zeal Terminal's engine currently reads an order side written as 100 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 34) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView. The live re-run is not offered here: the script requests heikinashi:SYMBOL D, heikinashi:BINANCE:BTCUSDT D, which this page cannot load in your browser.
Net profit
+19.99%
$99.96
Buy and hold
+102.5%
same period
Closed trades
41
16 won · 25 lost
Profitable
39.0%
of closed trades
Profit factor
1.13
gross profit ÷ gross loss
Max drawdown
42.87%
−$325.98

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

  • 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 security → request.security, heikinashi → ticker.heikinashi, sma → ta.sma.

v4 → v5

Verified

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

  • Line 4: //@version=4 → //@version=5
  • Line 9: security → request.security
  • Line 9: heikinashi → ticker.heikinashi
  • Line 10: security → request.security
  • Line 10: heikinashi → ticker.heikinashi
  • Line 11: security → request.security
6 more edits
  • Line 11: heikinashi → ticker.heikinashi
  • Line 22: sma → ta.sma
  • Line 23: sma → ta.sma
  • Line 27: sma → ta.sma
  • Line 28: sma → ta.sma
  • Line 34: strategy.entry(…, 100) → strategy.entry(…, strategy.long)
⋯// shiner.crypto@gmail.com-//@version=4+//@version=5strategy("Hi-Lo Channel Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, initial_capital=500, default_qty_value=100, currency="USD")⋯ha = input(true, "Use Heikin Ashi OHCL values (on real chart)?")-ha_h = security(heikinashi(syminfo.tickerid), timeframe.period, high)+ha_h = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)-ha_l = security(heikinashi(syminfo.tickerid), timeframe.period, low)+ha_l = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)-ha_c = security(heikinashi(syminfo.tickerid), timeframe.period, close)+ha_c = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)float mah = na⋯if ha == true-    mah := sma(ha_h, lenh)+    mah := ta.sma(ha_h, lenh)-    mal := sma(ha_l, lenl)+    mal := ta.sma(ha_l, lenl)    longCondition := ha_c > mah⋯if ha == false-    mah := sma(high, lenh)+    mah := ta.sma(high, lenh)-    mal := sma(low, lenl)+    mal := ta.sma(low, lenl)    longCondition := close > mah⋯if (longCondition)-    strategy.entry("Buy", 100)+    strategy.entry("Buy", strategy.long)if (shortCondition)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.bool()
⋯strategy("Hi-Lo Channel Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, initial_capital=500, default_qty_value=100, currency="USD")-lenh = input(5, "High-Based MA")+lenh = input.int(5, "High-Based MA")-lenl = input (5, "Low-Based MA")+lenl = input.int (5, "Low-Based MA")-ha = input(true, "Use Heikin Ashi OHCL values (on real chart)?")+ha = input.bool(true, "Use Heikin Ashi OHCL values (on real chart)?")ha_h = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)⋯

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: 41 before, 38 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.

⋯// shiner.crypto@gmail.com-//@version=5+//@version=6strategy("Hi-Lo Channel Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, initial_capital=500, default_qty_value=100, currency="USD")⋯

Settings

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

SettingDefaultType and rangeFeeds
High-Based MA5intmah
Low-Based MA5intmal
Use Heikin Ashi OHCL values (on real chart)?trueboolline 21 line 26

What it calculates

  • SMA (sma, ta.sma in v5)ha_h, High-Based MA (5)mah · line 22
  • SMA (sma, ta.sma in v5)ha_l, Low-Based MA (5)mal · line 23

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 datalenhHigh-Based MAsetting · 5lowlowprice datalenlLow-Based MAsetting · 5closecloseprice datamahSMA→ mahmalSMA→ malha_hha_hvalueha_lha_lvalueha_cha_cvaluelongConditionlongConditionconditionshortConditionshortConditionconditionentry:BuyOpen Buystrategy.entryclose:BuyClose Buystrategy.closeplot:31plotplotplot:32plotplot

Order rules

OrderFires whenBy defaultLine
Open Buy long(longCondition)On34
Close Buy(shortCondition)On36

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.

10/10trades 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 data3 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+20.0%+102.5%4139%1.1342.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+5.8%+5.5%3832%1.1613.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+6.1%+9.8%3824%1.0356.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−2.8%+8.4%3631%0.9518.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−11.3%+16.7%4043%0.9666.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+28.1%+21.5%3444%1.7010.6%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+53.8%+148.3%3546%1.2748.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+20.7%+17.1%3540%1.806.4%8 May 2026 – 21 Oct 2026

Higher-timeframe data for request.security(): heikinashi:SYMBOL D (Binance BTCUSDT 1d, as Heikin-Ashi by the engine), heikinashi:BINANCE:BTCUSDT D (Binance BTCUSDT 1d, as Heikin-Ashi by the engine), 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 market1145%−$17.20
Sideways market2339%$212.11
Falling market729%−$94.95

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

How bad could the drawdown be?

53.1%

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

0%61%
All 41 trades
SideEntryExitBarsP&L
long31 Jan 2024 42,941.1017 Mar 2024 65,300.6046$260.35
long26 Mar 2024 69,880.003 Apr 2024 65,464.008−$48.05
long9 Apr 2024 71,620.0014 Apr 2024 63,924.505−$76.54
long23 Apr 2024 66,819.3028 Apr 2024 63,462.005−$31.94
long5 May 2024 63,892.0012 Jun 2024 67,314.2038$32.34
long2 Jul 2024 62,900.005 Jul 2024 57,050.003−$59.17
long15 Jul 2024 60,797.9026 Jul 2024 65,799.9011$47.47
long28 Jul 2024 67,896.501 Aug 2024 64,628.004−$30.06
long10 Aug 2024 60,838.0028 Aug 2024 59,415.0018−$13.90
long11 Sep 2024 57,636.002 Oct 2024 60,804.9021$31.92
long8 Oct 2024 62,224.0010 Oct 2024 60,636.002−$15.63
long13 Oct 2024 63,206.2024 Oct 2024 66,668.6011$32.69
long29 Oct 2024 69,962.204 Nov 2024 68,776.006−$10.67
long7 Nov 2024 75,572.0027 Nov 2024 91,965.2020$134.23
long16 Dec 2024 104,464.0020 Dec 2024 97,461.904−$50.48
long4 Jan 2025 98,174.209 Jan 2025 95,060.605−$22.28
long16 Jan 2025 100,497.0028 Jan 2025 102,083.0012$10.73
long21 Feb 2025 98,305.0025 Feb 2025 91,552.904−$47.46
long3 Mar 2025 94,270.0010 Mar 2025 80,734.507−$92.40
long25 Mar 2025 87,498.2030 Mar 2025 82,648.505−$30.55
long13 Apr 2025 85,276.906 May 2025 94,733.7023$57.73
long8 May 2025 97,030.5030 May 2025 105,590.0022$51.02
long10 Jun 2025 110,263.0014 Jun 2025 106,067.004−$23.95
long25 Jun 2025 106,083.002 Aug 2025 113,298.0038$41.17
long8 Aug 2025 117,472.0017 Aug 2025 117,381.009−$0.50
long4 Sep 2025 111,706.0023 Sep 2025 112,651.0019$5.47
long30 Sep 2025 114,312.0011 Oct 2025 112,774.0011−$8.76
long27 Oct 2025 114,559.0031 Oct 2025 108,323.004−$34.99
long11 Nov 2025 106,011.0014 Nov 2025 99,692.003−$36.23
long28 Nov 2025 91,333.902 Dec 2025 86,286.004−$31.59
long4 Dec 2025 93,429.9015 Dec 2025 88,172.2011−$30.39
long4 Jan 2026 90,628.0020 Jan 2026 92,631.0016$11.26
long5 Mar 2026 72,666.809 Mar 2026 65,971.204−$47.99
long17 Mar 2026 74,884.7020 Mar 2026 69,930.003−$31.29
long7 Apr 2026 68,853.7029 Apr 2026 76,342.8022$48.03
long3 May 2026 78,686.8017 May 2026 78,148.1014−$3.35
long14 Jun 2026 64,458.0019 Jun 2026 62,958.005−$11.32
long4 Jul 2026 62,583.3026 Jul 2026 64,375.0022$13.60
long6 Aug 2026 64,665.2012 Aug 2026 63,600.006−$8.05
long19 Aug 2026 64,725.409 Sep 2026 78,455.8021$101.92
long19 Sep 2026 80,883.908 Oct 2026 83,321.8019$17.55

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
Hi-Lo Channel Strategy this page—v4 strategy+20.0%4142.9%
Follow the Crypto Shorts by xtradernetsmav4 strategyNo trades on this market
buy down and sell high trend 200 sma and ma cross by willi130503smav4 strategyNo trades on this market
Mayer Multiple Strategy by xtradernetsmav4 strategyNo trades on this market
Moving Average Cross Strategy early Closing by Geduldtradersmav4 strategy+73.8%20151.5%
MFI Simple Strategy by OztheWozsmav5 strategy−0.2%283.2%

Where it runs

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

Zeal Terminal's engine currently reads an order side written as 100 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 34) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView.

“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/// © shiner_trading// shiner.crypto@gmail.com//@version=4strategy("Hi-Lo Channel Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, initial_capital=500, default_qty_value=100, currency="USD")lenh = input(5, "High-Based MA")lenl = input (5, "Low-Based MA")ha = input(true, "Use Heikin Ashi OHCL values (on real chart)?")ha_h = security(heikinashi(syminfo.tickerid), timeframe.period, high)ha_l = security(heikinashi(syminfo.tickerid), timeframe.period, low)ha_c = security(heikinashi(syminfo.tickerid), timeframe.period, close)float mah = nafloat mal = nalongCondition = falseshortCondition = false/// HA is the check mark box in the configuration./// IF "Use Heikin Ashi OHCL values?" is true, then the strategy will use the Heikin Ashi close values// and therefore give the same buy/sell signals regardless of what chart you are viewing./// That being said, if "Use Heikin Ashi OHCL values?" is FALSE, yet you are viewing Heikin Ashi candles on your chart,// then logically you will also get the same buy/sell signalsif ha == true    mah := sma(ha_h, lenh)    mal := sma(ha_l, lenl)    longCondition := ha_c > mah    shortCondition := ha_c < malif ha == false    mah := sma(high, lenh)    mal := sma(low, lenl)    longCondition := close > mah    shortCondition := close < malplot(mah, color=color.green)plot(mal, color=color.red)if (longCondition)    strategy.entry("Buy", 100)if (shortCondition)    strategy.close("Buy")