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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Length | 3 | int · min 1 · step 1 | hi lo |
| Offset | 1 | int · min 0 · step 1 | hilo ghla |
| Begin from start? | false | bool | start_time |
| From Year | 2017 | int | start_time |
| From Month | 01 | int · min 1 · max 12 · step 1 | start_time |
| From Day | 01 | int · min 1 · max 31 · step 1 | start_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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | buyCondition and time >= start_time | On | 21 |
| Open Short short | sellCondition and time >= start_time | On | 23 |
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 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +5.2% | +102.5% | 131 | 36% | 1.10 | 10.2% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +1.2% | +5.5% | 143 | 34% | 1.06 | 3.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −8.1% | +9.8% | 135 | 30% | 0.91 | 16.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.4% | +8.4% | 141 | 30% | 0.98 | 4.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −3.0% | +16.7% | 137 | 36% | 0.97 | 18.4% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +8.2% | +21.5% | 125 | 40% | 1.32 | 4.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +9.3% | +148.3% | 131 | 38% | 1.14 | 9.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +4.3% | +17.1% | 137 | 37% | 1.23 | 4.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 48 | 33% | $61.44 |
| Sideways market | 53 | 40% | $17.61 |
| Falling market | 30 | 33% | −$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.
All 131 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 23 Feb 2024 50,744.20 | 26 Feb 2024 54,476.50 | 3 | −$14.71 |
| long | 26 Feb 2024 54,476.50 | 15 Mar 2024 69,499.90 | 18 | $54.34 |
| short | 15 Mar 2024 69,499.90 | 24 Mar 2024 67,210.00 | 9 | $6.85 |
| long | 24 Mar 2024 67,210.00 | 2 Apr 2024 65,464.00 | 9 | −$5.44 |
| short | 2 Apr 2024 65,464.00 | 6 Apr 2024 68,896.00 | 4 | −$10.92 |
| long | 6 Apr 2024 68,896.00 | 12 Apr 2024 67,116.50 | 6 | −$5.32 |
| short | 12 Apr 2024 67,116.50 | 20 Apr 2024 64,940.60 | 8 | $6.64 |
| long | 20 Apr 2024 64,940.60 | 24 Apr 2024 64,289.60 | 4 | −$2.07 |
| short | 24 Apr 2024 64,289.60 | 3 May 2024 62,882.00 | 9 | $4.51 |
| long | 3 May 2024 62,882.00 | 7 May 2024 62,312.10 | 4 | −$1.87 |
| short | 7 May 2024 62,312.10 | 13 May 2024 62,940.10 | 6 | −$2.08 |
| long | 13 May 2024 62,940.10 | 23 May 2024 67,969.60 | 10 | $16.46 |
| short | 23 May 2024 67,969.60 | 3 Jun 2024 68,809.90 | 11 | −$2.59 |
| long | 3 Jun 2024 68,809.90 | 7 Jun 2024 69,355.60 | 4 | $1.66 |
| short | 7 Jun 2024 69,355.60 | 30 Jun 2024 62,772.00 | 23 | $19.85 |
| long | 30 Jun 2024 62,772.00 | 3 Jul 2024 60,208.60 | 3 | −$8.70 |
| short | 3 Jul 2024 60,208.60 | 14 Jul 2024 60,797.90 | 11 | −$2.07 |
| long | 14 Jul 2024 60,797.90 | 23 Jul 2024 65,936.00 | 9 | $17.82 |
| short | 23 Jul 2024 65,936.00 | 26 Jul 2024 67,908.00 | 3 | −$6.41 |
| long | 26 Jul 2024 67,908.00 | 30 Jul 2024 66,188.00 | 4 | −$5.40 |
| short | 30 Jul 2024 66,188.00 | 8 Aug 2024 61,686.00 | 9 | $14.43 |
| long | 8 Aug 2024 61,686.00 | 12 Aug 2024 59,346.60 | 4 | −$8.15 |
| short | 12 Aug 2024 59,346.60 | 21 Aug 2024 61,156.00 | 9 | −$6.51 |
| long | 21 Aug 2024 61,156.00 | 27 Aug 2024 59,415.00 | 6 | −$6.04 |
| short | 27 Aug 2024 59,415.00 | 9 Sep 2024 57,042.00 | 13 | $8.42 |
| long | 9 Sep 2024 57,042.00 | 16 Sep 2024 58,214.00 | 7 | $4.37 |
| short | 16 Sep 2024 58,214.00 | 17 Sep 2024 60,314.00 | 1 | −$7.70 |
| long | 17 Sep 2024 60,314.00 | 30 Sep 2024 63,327.60 | 13 | $10.59 |
| short | 30 Sep 2024 63,327.60 | 6 Oct 2024 62,819.90 | 6 | $1.72 |
| long | 6 Oct 2024 62,819.90 | 9 Oct 2024 60,636.00 | 3 | −$7.45 |
| short | 9 Oct 2024 60,636.00 | 11 Oct 2024 62,540.00 | 2 | −$6.68 |
| long | 11 Oct 2024 62,540.00 | 21 Oct 2024 67,377.50 | 10 | $16.36 |
| short | 21 Oct 2024 67,377.50 | 28 Oct 2024 69,962.20 | 7 | −$8.24 |
| long | 28 Oct 2024 69,962.20 | 1 Nov 2024 69,496.00 | 4 | −$1.42 |
| short | 1 Nov 2024 69,496.00 | 6 Nov 2024 75,572.00 | 5 | −$18.61 |
| long | 6 Nov 2024 75,572.00 | 25 Nov 2024 93,010.00 | 19 | $48.26 |
| short | 25 Nov 2024 93,010.00 | 29 Nov 2024 97,460.00 | 4 | −$10.47 |
| long | 29 Nov 2024 97,460.00 | 9 Dec 2024 97,276.50 | 10 | −$0.41 |
| short | 9 Dec 2024 97,276.50 | 11 Dec 2024 101,125.00 | 2 | −$8.57 |
| long | 11 Dec 2024 101,125.00 | 18 Dec 2024 100,204.00 | 7 | −$1.96 |
| short | 18 Dec 2024 100,204.00 | 24 Dec 2024 98,663.60 | 6 | $3.30 |
| long | 24 Dec 2024 98,663.60 | 27 Dec 2024 94,299.00 | 3 | −$9.52 |
| short | 27 Dec 2024 94,299.00 | 2 Jan 2025 96,984.80 | 6 | −$6.07 |
| long | 2 Jan 2025 96,984.80 | 7 Jan 2025 96,954.60 | 5 | −$0.07 |
| short | 7 Jan 2025 96,954.60 | 14 Jan 2025 96,560.90 | 7 | $0.86 |
| long | 14 Jan 2025 96,560.90 | 26 Jan 2025 102,620.00 | 12 | $13.32 |
| short | 26 Jan 2025 102,620.00 | 30 Jan 2025 104,723.00 | 4 | −$4.40 |
| long | 30 Jan 2025 104,723.00 | 1 Feb 2025 100,636.00 | 2 | −$8.35 |
| short | 1 Feb 2025 100,636.00 | 20 Feb 2025 98,305.00 | 19 | $4.92 |
| long | 20 Feb 2025 98,305.00 | 24 Feb 2025 91,552.90 | 4 | −$14.65 |
| short | 24 Feb 2025 91,552.90 | 2 Mar 2025 94,270.00 | 6 | −$6.24 |
| long | 2 Mar 2025 94,270.00 | 8 Mar 2025 86,222.40 | 6 | −$17.85 |
| short | 8 Mar 2025 86,222.40 | 19 Mar 2025 86,845.90 | 11 | −$1.49 |
| long | 19 Mar 2025 86,845.90 | 28 Mar 2025 84,424.40 | 9 | −$5.72 |
| short | 28 Mar 2025 84,424.40 | 1 Apr 2025 85,158.30 | 4 | −$1.77 |
| long | 1 Apr 2025 85,158.30 | 6 Apr 2025 78,430.00 | 5 | −$16.10 |
| short | 6 Apr 2025 78,430.00 | 9 Apr 2025 82,615.20 | 3 | −$10.70 |
| long | 9 Apr 2025 82,615.20 | 4 May 2025 94,277.60 | 25 | $28.01 |
| short | 4 May 2025 94,277.60 | 6 May 2025 96,834.00 | 2 | −$5.53 |
| long | 6 May 2025 96,834.00 | 12 May 2025 102,791.00 | 6 | $12.48 |
| short | 12 May 2025 102,791.00 | 18 May 2025 106,454.00 | 6 | −$7.32 |
| long | 18 May 2025 106,454.00 | 29 May 2025 105,590.00 | 11 | −$1.66 |
| short | 29 May 2025 105,590.00 | 2 Jun 2025 105,858.00 | 4 | −$0.52 |
| long | 2 Jun 2025 105,858.00 | 5 Jun 2025 101,509.00 | 3 | −$8.36 |
| short | 5 Jun 2025 101,509.00 | 8 Jun 2025 105,734.00 | 3 | −$8.40 |
| long | 8 Jun 2025 105,734.00 | 12 Jun 2025 105,672.00 | 4 | −$0.12 |
| short | 12 Jun 2025 105,672.00 | 16 Jun 2025 106,795.00 | 4 | −$2.13 |
| long | 16 Jun 2025 106,795.00 | 17 Jun 2025 104,551.00 | 1 | −$4.19 |
| short | 17 Jun 2025 104,551.00 | 23 Jun 2025 105,334.00 | 6 | −$1.49 |
| long | 23 Jun 2025 105,334.00 | 1 Jul 2025 105,681.00 | 8 | $0.65 |
| short | 1 Jul 2025 105,681.00 | 2 Jul 2025 108,850.00 | 1 | −$5.96 |
| long | 2 Jul 2025 108,850.00 | 31 Jul 2025 115,764.00 | 29 | $12.54 |
| short | 31 Jul 2025 115,764.00 | 4 Aug 2025 115,055.00 | 4 | $1.22 |
| long | 4 Aug 2025 115,055.00 | 14 Aug 2025 118,295.00 | 10 | $5.64 |
| short | 14 Aug 2025 118,295.00 | 22 Aug 2025 116,936.00 | 8 | $2.31 |
| long | 22 Aug 2025 116,936.00 | 25 Aug 2025 110,112.00 | 3 | −$11.78 |
| short | 25 Aug 2025 110,112.00 | 2 Sep 2025 111,240.00 | 8 | −$2.04 |
| long | 2 Sep 2025 111,240.00 | 21 Sep 2025 115,232.00 | 19 | $7.14 |
| short | 21 Sep 2025 115,232.00 | 28 Sep 2025 112,164.00 | 7 | $5.34 |
| long | 28 Sep 2025 112,164.00 | 7 Oct 2025 121,333.00 | 9 | $16.48 |
| short | 7 Oct 2025 121,333.00 | 20 Oct 2025 110,532.00 | 13 | $18.24 |
| long | 20 Oct 2025 110,532.00 | 29 Oct 2025 110,021.00 | 9 | −$0.96 |
| short | 29 Oct 2025 110,021.00 | 9 Nov 2025 104,723.00 | 11 | $10.03 |
| long | 9 Nov 2025 104,723.00 | 12 Nov 2025 101,654.00 | 3 | −$6.16 |
| short | 12 Nov 2025 101,654.00 | 24 Nov 2025 88,300.00 | 12 | $27.47 |
| long | 24 Nov 2025 88,300.00 | 1 Dec 2025 86,286.00 | 7 | −$4.89 |
| short | 1 Dec 2025 86,286.00 | 2 Dec 2025 91,277.90 | 1 | −$12.36 |
| long | 2 Dec 2025 91,277.90 | 5 Dec 2025 89,330.00 | 3 | −$4.51 |
| short | 5 Dec 2025 89,330.00 | 9 Dec 2025 92,678.80 | 4 | −$7.88 |
| long | 9 Dec 2025 92,678.80 | 14 Dec 2025 88,172.20 | 5 | −$10.15 |
| short | 14 Dec 2025 88,172.20 | 2 Jan 2026 89,995.10 | 19 | −$4.27 |
| long | 2 Jan 2026 89,995.10 | 8 Jan 2026 91,100.00 | 6 | $2.53 |
| short | 8 Jan 2026 91,100.00 | 13 Jan 2026 95,414.00 | 5 | −$9.77 |
| long | 13 Jan 2026 95,414.00 | 18 Jan 2026 93,673.10 | 5 | −$3.73 |
| short | 18 Jan 2026 93,673.10 | 28 Jan 2026 89,300.00 | 10 | $9.50 |
| long | 28 Jan 2026 89,300.00 | 29 Jan 2026 84,650.20 | 1 | −$10.70 |
| short | 29 Jan 2026 84,650.20 | 14 Feb 2026 69,822.90 | 16 | $35.62 |
| long | 14 Feb 2026 69,822.90 | 17 Feb 2026 67,503.50 | 3 | −$6.99 |
| short | 17 Feb 2026 67,503.50 | 25 Feb 2026 67,988.00 | 8 | −$1.50 |
| long | 25 Feb 2026 67,988.00 | 7 Mar 2026 67,262.90 | 10 | −$2.23 |
| short | 7 Mar 2026 67,262.90 | 10 Mar 2026 69,948.60 | 3 | −$8.32 |
| long | 10 Mar 2026 69,948.60 | 18 Mar 2026 71,246.50 | 8 | $3.83 |
| short | 18 Mar 2026 71,246.50 | 23 Mar 2026 70,906.40 | 5 | $0.99 |
| long | 23 Mar 2026 70,906.40 | 26 Mar 2026 68,820.30 | 3 | −$6.11 |
| short | 26 Mar 2026 68,820.30 | 31 Mar 2026 68,284.50 | 5 | $1.61 |
| long | 31 Mar 2026 68,284.50 | 12 Apr 2026 70,741.00 | 12 | $7.44 |
| short | 12 Apr 2026 70,741.00 | 13 Apr 2026 74,418.00 | 1 | −$10.82 |
| long | 13 Apr 2026 74,418.00 | 19 Apr 2026 73,801.80 | 6 | −$1.71 |
| short | 19 Apr 2026 73,801.80 | 22 Apr 2026 78,178.20 | 3 | −$12.20 |
| long | 22 Apr 2026 78,178.20 | 28 Apr 2026 76,342.80 | 6 | −$4.77 |
| short | 28 Apr 2026 76,342.80 | 1 May 2026 78,231.10 | 3 | −$5.00 |
| long | 1 May 2026 78,231.10 | 13 May 2026 79,313.60 | 12 | $2.79 |
| short | 13 May 2026 79,313.60 | 11 Jun 2026 63,626.00 | 29 | $39.93 |
| long | 11 Jun 2026 63,626.00 | 17 Jun 2026 64,509.40 | 6 | $2.91 |
| short | 17 Jun 2026 64,509.40 | 2 Jul 2026 61,560.00 | 15 | $9.62 |
| long | 2 Jul 2026 61,560.00 | 13 Jul 2026 62,334.50 | 11 | $2.67 |
| short | 13 Jul 2026 62,334.50 | 14 Jul 2026 65,044.00 | 1 | −$9.25 |
| long | 14 Jul 2026 65,044.00 | 24 Jul 2026 64,140.00 | 10 | −$2.93 |
| short | 24 Jul 2026 64,140.00 | 4 Aug 2026 64,106.60 | 11 | $0.11 |
| long | 4 Aug 2026 64,106.60 | 10 Aug 2026 63,970.00 | 6 | −$0.45 |
| short | 10 Aug 2026 63,970.00 | 17 Aug 2026 64,532.10 | 7 | −$1.85 |
| long | 17 Aug 2026 64,532.10 | 28 Aug 2026 77,845.90 | 11 | $43.33 |
| short | 28 Aug 2026 77,845.90 | 3 Sep 2026 81,270.40 | 6 | −$9.62 |
| long | 3 Sep 2026 81,270.40 | 8 Sep 2026 78,455.80 | 5 | −$7.51 |
| short | 8 Sep 2026 78,455.80 | 18 Sep 2026 80,883.90 | 10 | −$6.66 |
| long | 18 Sep 2026 80,883.90 | 28 Sep 2026 83,500.00 | 10 | $6.92 |
| short | 28 Sep 2026 83,500.00 | 4 Oct 2026 86,530.00 | 6 | −$7.81 |
| long | 4 Oct 2026 86,530.00 | 7 Oct 2026 83,321.80 | 3 | −$7.92 |
| short | 7 Oct 2026 83,321.80 | 11 Oct 2026 83,773.10 | 4 | −$1.15 |
| long | 11 Oct 2026 83,773.10 | 12 Oct 2026 81,850.00 | 1 | −$4.86 |
| short | 12 Oct 2026 81,850.00 | 20 Oct 2026 83,028.10 | 8 | −$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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Gann HiLo Activator Strategy this page | — | v5 strategy | +5.2% | 131 | 10.2% |
| Follow the Crypto Shorts by xtradernet | sma | v4 strategy | No trades on this market | ||
| buy down and sell high trend 200 sma and ma cross by willi130503 | sma | v4 strategy | No trades on this market | ||
| Mayer Multiple Strategy by xtradernet | sma | v4 strategy | No trades on this market | ||
| Moving Average Cross Strategy early Closing by Geduldtrader | sma | v4 strategy | +73.8% | 20 | 151.5% |
| MFI Simple Strategy by OztheWoz | sma | v5 strategy | −0.2% | 28 | 3.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.
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.
⋯// © 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 11 ms | Yes 1,000 bars in 30 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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)