Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Gann HiLo Activator Strategy

A Pine Script v5 strategy built on SMA (high, 3). 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 commits 20% of equity and pays no commission. 6 settings; defaults include Length 3, Offset 1 and From Year 2017.

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 Gann HiLo Activator Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 40 of 40 trades.
How did Gann HiLo Activator Strategy do on BTCUSDT 1D with default settings?
+5.17%
From 26 Jan 2024 to 21 Oct 2026, over 131 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Gann HiLo Activator Strategy run in Pine Script v6?
Yes
Same 131 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Gann HiLo Activator Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Gann HiLo Activator Strategy run in Zeal Terminal?
Yes
It compiles in 11 ms and runs 1,000 bars in 30 ms, in the browser.

BTCUSDT · 1D · default settings

  • 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 (6)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,056$2,025Equity from $1,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
+5.17%
$51.72
Buy and hold
+102.5%
same period
Closed trades
131
47 won · 84 lost
Profitable
35.9%
of closed trades
Profit factor
1.10
gross profit ÷ gross loss
Max drawdown
10.23%
−$111.92

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

    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
Length3int · min 1 · step 1hi lo
Offset1int · min 0 · step 1hilo ghla
Begin from start?falseboolstart_time
From Year2017intstart_time
From Month01int · min 1 · max 12 · step 1start_time
From Day01int · min 1 · max 31 · step 1start_time

What it calculates

  • SMAhigh, Length (3)hi · line 13
  • SMAlow, Length (3)lo · line 14

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 datalenLengthsetting · 3lowlowprice databacktest_yearFrom Yearsetting · 2017backtest_monthFrom Monthsetting · 01backtest_dayFrom Daysetting · 01closecloseprice datadisplaceOffsetsetting · 1timetimeprice datahiSMA→ hiloSMA→ lostart_timestart_timevaluehilohilovalueghlaghlavaluebuyConditionbuyConditionconditionsellConditionsellConditionconditioncolorColourcolorentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryplot:24plotplot

Order rules

OrderFires whenBy defaultLine
Open Long longbuyCondition and time >= start_timeOn21
Open Short shortsellCondition and time >= start_timeOn23

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.

40/40trades 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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+5.2%+102.5%13136%1.1010.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.2%+5.5%14334%1.063.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−8.1%+9.8%13530%0.9116.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.4%+8.4%14130%0.984.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−3.0%+16.7%13736%0.9718.4%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+8.2%+21.5%12540%1.324.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+9.3%+148.3%13138%1.149.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+4.3%+17.1%13737%1.234.7%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 market4833%$61.44
Sideways market5340%$17.61
Falling market3033%−$27.33

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

How bad could the drawdown be?

16.0%

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

0%18%
All 131 trades
SideEntryExitBarsP&L
short23 Feb 2024 50,744.2026 Feb 2024 54,476.503−$14.71
long26 Feb 2024 54,476.5015 Mar 2024 69,499.9018$54.34
short15 Mar 2024 69,499.9024 Mar 2024 67,210.009$6.85
long24 Mar 2024 67,210.002 Apr 2024 65,464.009−$5.44
short2 Apr 2024 65,464.006 Apr 2024 68,896.004−$10.92
long6 Apr 2024 68,896.0012 Apr 2024 67,116.506−$5.32
short12 Apr 2024 67,116.5020 Apr 2024 64,940.608$6.64
long20 Apr 2024 64,940.6024 Apr 2024 64,289.604−$2.07
short24 Apr 2024 64,289.603 May 2024 62,882.009$4.51
long3 May 2024 62,882.007 May 2024 62,312.104−$1.87
short7 May 2024 62,312.1013 May 2024 62,940.106−$2.08
long13 May 2024 62,940.1023 May 2024 67,969.6010$16.46
short23 May 2024 67,969.603 Jun 2024 68,809.9011−$2.59
long3 Jun 2024 68,809.907 Jun 2024 69,355.604$1.66
short7 Jun 2024 69,355.6030 Jun 2024 62,772.0023$19.85
long30 Jun 2024 62,772.003 Jul 2024 60,208.603−$8.70
short3 Jul 2024 60,208.6014 Jul 2024 60,797.9011−$2.07
long14 Jul 2024 60,797.9023 Jul 2024 65,936.009$17.82
short23 Jul 2024 65,936.0026 Jul 2024 67,908.003−$6.41
long26 Jul 2024 67,908.0030 Jul 2024 66,188.004−$5.40
short30 Jul 2024 66,188.008 Aug 2024 61,686.009$14.43
long8 Aug 2024 61,686.0012 Aug 2024 59,346.604−$8.15
short12 Aug 2024 59,346.6021 Aug 2024 61,156.009−$6.51
long21 Aug 2024 61,156.0027 Aug 2024 59,415.006−$6.04
short27 Aug 2024 59,415.009 Sep 2024 57,042.0013$8.42
long9 Sep 2024 57,042.0016 Sep 2024 58,214.007$4.37
short16 Sep 2024 58,214.0017 Sep 2024 60,314.001−$7.70
long17 Sep 2024 60,314.0030 Sep 2024 63,327.6013$10.59
short30 Sep 2024 63,327.606 Oct 2024 62,819.906$1.72
long6 Oct 2024 62,819.909 Oct 2024 60,636.003−$7.45
short9 Oct 2024 60,636.0011 Oct 2024 62,540.002−$6.68
long11 Oct 2024 62,540.0021 Oct 2024 67,377.5010$16.36
short21 Oct 2024 67,377.5028 Oct 2024 69,962.207−$8.24
long28 Oct 2024 69,962.201 Nov 2024 69,496.004−$1.42
short1 Nov 2024 69,496.006 Nov 2024 75,572.005−$18.61
long6 Nov 2024 75,572.0025 Nov 2024 93,010.0019$48.26
short25 Nov 2024 93,010.0029 Nov 2024 97,460.004−$10.47
long29 Nov 2024 97,460.009 Dec 2024 97,276.5010−$0.41
short9 Dec 2024 97,276.5011 Dec 2024 101,125.002−$8.57
long11 Dec 2024 101,125.0018 Dec 2024 100,204.007−$1.96
short18 Dec 2024 100,204.0024 Dec 2024 98,663.606$3.30
long24 Dec 2024 98,663.6027 Dec 2024 94,299.003−$9.52
short27 Dec 2024 94,299.002 Jan 2025 96,984.806−$6.07
long2 Jan 2025 96,984.807 Jan 2025 96,954.605−$0.07
short7 Jan 2025 96,954.6014 Jan 2025 96,560.907$0.86
long14 Jan 2025 96,560.9026 Jan 2025 102,620.0012$13.32
short26 Jan 2025 102,620.0030 Jan 2025 104,723.004−$4.40
long30 Jan 2025 104,723.001 Feb 2025 100,636.002−$8.35
short1 Feb 2025 100,636.0020 Feb 2025 98,305.0019$4.92
long20 Feb 2025 98,305.0024 Feb 2025 91,552.904−$14.65
short24 Feb 2025 91,552.902 Mar 2025 94,270.006−$6.24
long2 Mar 2025 94,270.008 Mar 2025 86,222.406−$17.85
short8 Mar 2025 86,222.4019 Mar 2025 86,845.9011−$1.49
long19 Mar 2025 86,845.9028 Mar 2025 84,424.409−$5.72
short28 Mar 2025 84,424.401 Apr 2025 85,158.304−$1.77
long1 Apr 2025 85,158.306 Apr 2025 78,430.005−$16.10
short6 Apr 2025 78,430.009 Apr 2025 82,615.203−$10.70
long9 Apr 2025 82,615.204 May 2025 94,277.6025$28.01
short4 May 2025 94,277.606 May 2025 96,834.002−$5.53
long6 May 2025 96,834.0012 May 2025 102,791.006$12.48
short12 May 2025 102,791.0018 May 2025 106,454.006−$7.32
long18 May 2025 106,454.0029 May 2025 105,590.0011−$1.66
short29 May 2025 105,590.002 Jun 2025 105,858.004−$0.52
long2 Jun 2025 105,858.005 Jun 2025 101,509.003−$8.36
short5 Jun 2025 101,509.008 Jun 2025 105,734.003−$8.40
long8 Jun 2025 105,734.0012 Jun 2025 105,672.004−$0.12
short12 Jun 2025 105,672.0016 Jun 2025 106,795.004−$2.13
long16 Jun 2025 106,795.0017 Jun 2025 104,551.001−$4.19
short17 Jun 2025 104,551.0023 Jun 2025 105,334.006−$1.49
long23 Jun 2025 105,334.001 Jul 2025 105,681.008$0.65
short1 Jul 2025 105,681.002 Jul 2025 108,850.001−$5.96
long2 Jul 2025 108,850.0031 Jul 2025 115,764.0029$12.54
short31 Jul 2025 115,764.004 Aug 2025 115,055.004$1.22
long4 Aug 2025 115,055.0014 Aug 2025 118,295.0010$5.64
short14 Aug 2025 118,295.0022 Aug 2025 116,936.008$2.31
long22 Aug 2025 116,936.0025 Aug 2025 110,112.003−$11.78
short25 Aug 2025 110,112.002 Sep 2025 111,240.008−$2.04
long2 Sep 2025 111,240.0021 Sep 2025 115,232.0019$7.14
short21 Sep 2025 115,232.0028 Sep 2025 112,164.007$5.34
long28 Sep 2025 112,164.007 Oct 2025 121,333.009$16.48
short7 Oct 2025 121,333.0020 Oct 2025 110,532.0013$18.24
long20 Oct 2025 110,532.0029 Oct 2025 110,021.009−$0.96
short29 Oct 2025 110,021.009 Nov 2025 104,723.0011$10.03
long9 Nov 2025 104,723.0012 Nov 2025 101,654.003−$6.16
short12 Nov 2025 101,654.0024 Nov 2025 88,300.0012$27.47
long24 Nov 2025 88,300.001 Dec 2025 86,286.007−$4.89
short1 Dec 2025 86,286.002 Dec 2025 91,277.901−$12.36
long2 Dec 2025 91,277.905 Dec 2025 89,330.003−$4.51
short5 Dec 2025 89,330.009 Dec 2025 92,678.804−$7.88
long9 Dec 2025 92,678.8014 Dec 2025 88,172.205−$10.15
short14 Dec 2025 88,172.202 Jan 2026 89,995.1019−$4.27
long2 Jan 2026 89,995.108 Jan 2026 91,100.006$2.53
short8 Jan 2026 91,100.0013 Jan 2026 95,414.005−$9.77
long13 Jan 2026 95,414.0018 Jan 2026 93,673.105−$3.73
short18 Jan 2026 93,673.1028 Jan 2026 89,300.0010$9.50
long28 Jan 2026 89,300.0029 Jan 2026 84,650.201−$10.70
short29 Jan 2026 84,650.2014 Feb 2026 69,822.9016$35.62
long14 Feb 2026 69,822.9017 Feb 2026 67,503.503−$6.99
short17 Feb 2026 67,503.5025 Feb 2026 67,988.008−$1.50
long25 Feb 2026 67,988.007 Mar 2026 67,262.9010−$2.23
short7 Mar 2026 67,262.9010 Mar 2026 69,948.603−$8.32
long10 Mar 2026 69,948.6018 Mar 2026 71,246.508$3.83
short18 Mar 2026 71,246.5023 Mar 2026 70,906.405$0.99
long23 Mar 2026 70,906.4026 Mar 2026 68,820.303−$6.11
short26 Mar 2026 68,820.3031 Mar 2026 68,284.505$1.61
long31 Mar 2026 68,284.5012 Apr 2026 70,741.0012$7.44
short12 Apr 2026 70,741.0013 Apr 2026 74,418.001−$10.82
long13 Apr 2026 74,418.0019 Apr 2026 73,801.806−$1.71
short19 Apr 2026 73,801.8022 Apr 2026 78,178.203−$12.20
long22 Apr 2026 78,178.2028 Apr 2026 76,342.806−$4.77
short28 Apr 2026 76,342.801 May 2026 78,231.103−$5.00
long1 May 2026 78,231.1013 May 2026 79,313.6012$2.79
short13 May 2026 79,313.6011 Jun 2026 63,626.0029$39.93
long11 Jun 2026 63,626.0017 Jun 2026 64,509.406$2.91
short17 Jun 2026 64,509.402 Jul 2026 61,560.0015$9.62
long2 Jul 2026 61,560.0013 Jul 2026 62,334.5011$2.67
short13 Jul 2026 62,334.5014 Jul 2026 65,044.001−$9.25
long14 Jul 2026 65,044.0024 Jul 2026 64,140.0010−$2.93
short24 Jul 2026 64,140.004 Aug 2026 64,106.6011$0.11
long4 Aug 2026 64,106.6010 Aug 2026 63,970.006−$0.45
short10 Aug 2026 63,970.0017 Aug 2026 64,532.107−$1.85
long17 Aug 2026 64,532.1028 Aug 2026 77,845.9011$43.33
short28 Aug 2026 77,845.903 Sep 2026 81,270.406−$9.62
long3 Sep 2026 81,270.408 Sep 2026 78,455.805−$7.51
short8 Sep 2026 78,455.8018 Sep 2026 80,883.9010−$6.66
long18 Sep 2026 80,883.9028 Sep 2026 83,500.0010$6.92
short28 Sep 2026 83,500.004 Oct 2026 86,530.006−$7.81
long4 Oct 2026 86,530.007 Oct 2026 83,321.803−$7.92
short7 Oct 2026 83,321.8011 Oct 2026 83,773.104−$1.15
long11 Oct 2026 83,773.1012 Oct 2026 81,850.001−$4.86
short12 Oct 2026 81,850.0020 Oct 2026 83,028.108−$3.04

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
Gann HiLo Activator Strategy this page—v5 strategy+5.2%13110.2%
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%

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 7, 8). 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 131 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 7: input() → input.bool()
  • Line 8: input() → input.int()
⋯displace = input.int(1, 'Offset', step=1, minval=0)-from_start = input(false, 'Begin from start?')+from_start = input.bool(false, 'Begin from start?')-backtest_year = input(2017, 'From Year')+backtest_year = input.int(2017, 'From Year')backtest_month = input.int(01, 'From Month', minval=1, maxval=12, step=1)⋯

Does it run in Pine Script v6?

Yes

Same 131 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © starbolt-//@version=5+//@version=6strategy('Gann HiLo Activator Strategy', overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=1000, process_orders_on_close=true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 11 msYes 1,000 bars in 30 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/// © starbolt//@version=5strategy('Gann HiLo Activator Strategy', overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=1000, process_orders_on_close=true)len = input.int(3, 'Length', step=1, minval=1)displace = input.int(1, 'Offset', step=1, minval=0)from_start = input(false, 'Begin from start?')backtest_year = input(2017, 'From Year')backtest_month = input.int(01, 'From Month', minval=1, maxval=12, step=1)backtest_day = input.int(01, 'From Day', minval=1, maxval=31, step=1)start_time = from_start ? 0 : timestamp(backtest_year, backtest_month, backtest_day, 00, 00)float hilo = nahi = ta.sma(high, len)lo = ta.sma(low, len)hilo := close > hi[displace] ? 1 : close < lo[displace] ? -1 : hilo[1]ghla = hilo == -1 ? hi[displace] : lo[displace]color = hilo == -1 ? color.red : color.greenbuyCondition = hilo == 1 and hilo[1] == -1sellCondition = hilo == -1 and hilo[1] == 1if buyCondition and time >= start_time    strategy.entry('Long', strategy.long)if sellCondition and time >= start_time    strategy.entry('Short', strategy.short)plot(ghla, color=color, style=plot.style_cross)