Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

GRB Long

A Pine Script v4 strategy built on Highest (high, 21) and Lowest (low, 21). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 5 settings; defaults include High Days 21, Low Days 21 and Start Date 1.

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 GRB Long repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 9 of 9 trades.
How did GRB Long do on BTCUSDT 1D with default settings?
+13.91%
From 26 Jan 2024 to 21 Oct 2026, over 33 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can GRB Long 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 GRB Long use a stop loss?
Yes
strategy.exit sets a stop on line 22.
Does GRB Long run in Zeal Terminal?
Yes
It compiles in 8 ms and runs 1,000 bars in 25 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • 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 (5)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$113,913$202,527Equity from $100,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
+13.91%
$13,909.90
Buy and hold
+102.5%
same period
Closed trades
33
10 won · 23 lost
Profitable
30.3%
of closed trades
Profit factor
1.17
gross profit ÷ gross loss
Max drawdown
31.15%
−$42,614.60

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

    No slippage

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

  • Note

    Uses an argument v6 removed

    when = on line 21. 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 highest → ta.highest, lowest → ta.lowest.
  • 1 strategy call uses the when = argument (line 21). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 5: input(type = input.integer) → input.int()
  • Line 6: input(type = input.integer) → input.int()
  • Line 8: input(type = input.integer) → input.int()
  • Line 10: input(type = input.integer) → input.int()
  • Line 12: input(type = input.integer) → input.int()
  • Line 17: highest → ta.highest
  • Line 18: lowest → ta.lowest
⋯// © omkarkondhekar-//@version=4+//@version=5strategy("GRBLong", overlay=true)-highInput = input(title = "High Days", type = input.integer, defval = 21, minval = 11)+highInput = input.int(title = "High Days", defval = 21, minval = 11)-lowInput = input(title = "Low Days", type = input.integer, defval = 21, minval = 5)+lowInput = input.int(title = "Low Days", defval = 21, minval = 5)// Configure backtest start date with inputs-startDate = input(title="Start Date", type=input.integer,+startDate = input.int(title="Start Date",     defval=1, minval=1, maxval=31)-startMonth = input(title="Start Month", type=input.integer,+startMonth = input.int(title="Start Month",     defval=1, minval=1, maxval=12)-startYear = input(title="Start Year", type=input.integer,+startYear = input.int(title="Start Year",     defval=2019, minval=1800, maxval=2100)⋯     startYear, startMonth, startDate, 0, 0))-high21 = highest(high, highInput)+high21 = ta.highest(high, highInput)-low21 = lowest(low, lowInput)+low21 = ta.lowest(low, lowInput)diff = high21 - low21⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 21: when = longEntrySignal and afterStartDate → if block
⋯longEntrySignal = low > low21 + (diff * 0.382) and close[1] > open[1] -strategy.entry("Long", strategy.long, when = longEntrySignal and afterStartDate)+if longEntrySignal and afterStartDate+    strategy.entry("Long", strategy.long)strategy.exit("Long Exit", "Long", stop = low21 + (diff * 0.236))⋯

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: 33 before, 30 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.

⋯// © omkarkondhekar-//@version=5+//@version=6strategy("GRBLong", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
High Days21int (written input.integer) · min 11high21
Low Days21int (written input.integer) · min 5low21
Start Date1int (written input.integer) · min 1 · max 31afterStartDate
Start Month1int (written input.integer) · min 1 · max 12afterStartDate
Start Year2019int (written input.integer) · min 1800 · max 2100afterStartDate

What it calculates

  • Highest (highest, ta.highest in v5)high, High Days (21)high21 · line 17
  • Lowest (lowest, ta.lowest in v5)low, Low Days (21)low21 · line 18

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 datahighInputHigh Dayssetting · 21lowlowprice datalowInputLow Dayssetting · 21timetimeprice datastartYearStart Yearsetting · 2019startMonthStart Monthsetting · 1startDateStart Datesetting · 1openopenprice dataclosecloseprice datahigh21Highest→ high21low21Lowest→ low21diffdiffvalueafterStartDateafterStartDateconditionlongEntrySignallongEntrySignalconditionentry:LongOpen Longstrategy.entryexit:Long Exitexit Long Exitstrategy.exitplot:23plotplotplot:24plotplot

Order rules

OrderFires whenBy defaultLine
Open Long longlongEntrySignal and afterStartDateOn21
Exit Long Exit stopevery barOn22

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.

9/9trades 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+13.9%+102.5%3330%1.1731.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−4.5%+5.5%3722%0.8514.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.0%+9.8%3722%0.842.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.2%+8.4%3719%0.860.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%3231%0.920.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%3219%1.250.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.3%+148.3%3037%1.410.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%3132%1.400.1%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 market1040%−$187.20
Sideways market1631%$23,684.70
Falling market714%−$9,587.66

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

How bad could the drawdown be?

36.2%

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

0%42%
All 33 trades
SideEntryExitBarsP&L
long16 Feb 2024 51,880.0022 Mar 2024 62,491.2035$10,611.20
long26 Mar 2024 69,880.0013 Apr 2024 65,312.3018−$4,567.68
long24 Apr 2024 66,414.0027 Apr 2024 62,714.703−$3,699.27
long5 May 2024 63,892.0011 Jun 2024 67,653.8037$3,761.75
long14 Jul 2024 59,204.003 Aug 2024 60,664.9020$1,460.93
long10 Aug 2024 60,838.0030 Aug 2024 58,184.0020−$2,653.99
long14 Sep 2024 60,498.009 Oct 2024 60,903.1025$405.08
long13 Oct 2024 63,206.2020 Dec 2024 94,713.3068$31,507.10
long26 Dec 2024 99,429.6027 Dec 2024 95,791.601−$3,638.01
long16 Jan 2025 100,497.003 Feb 2025 94,054.9018−$6,442.48
long16 Feb 2025 97,569.7018 Feb 2025 94,824.402−$2,745.24
long7 Mar 2025 89,931.909 Mar 2025 83,265.602−$6,666.28
long21 Mar 2025 84,223.403 Apr 2025 82,022.7013−$2,200.66
long13 Apr 2025 85,276.9031 May 2025 103,376.0048$18,099.20
long9 Jun 2025 105,734.0013 Jun 2025 103,069.004−$2,664.81
long17 Jun 2025 106,795.0020 Jun 2025 102,770.003−$4,025.01
long25 Jun 2025 106,083.001 Aug 2025 115,764.0037$9,681.07
long9 Aug 2025 116,675.0018 Aug 2025 114,883.009−$1,792.00
long12 Sep 2025 115,483.0024 Sep 2025 111,352.0012−$4,130.85
long1 Oct 2025 114,049.0010 Oct 2025 112,769.009−$1,280.10
long14 Oct 2025 115,166.0016 Oct 2025 107,711.002−$7,454.89
long27 Oct 2025 114,559.0030 Oct 2025 107,136.003−$7,423.36
long2 Nov 2025 110,098.003 Nov 2025 106,566.001−$3,532.14
long4 Dec 2025 93,429.9015 Dec 2025 86,363.6011−$7,066.36
long3 Jan 2026 89,995.1020 Jan 2026 89,460.3017−$534.88
long22 Feb 2026 67,975.9023 Feb 2026 64,569.001−$3,406.97
long27 Feb 2026 67,485.2028 Feb 2026 64,813.901−$2,671.29
long4 Mar 2026 68,338.0022 Mar 2026 67,638.8018−$699.23
long9 Apr 2026 71,069.9017 May 2026 76,804.9038$5,734.93
long5 Jul 2026 63,144.0028 Jul 2026 62,821.7023−$322.32
long7 Aug 2026 64,323.6011 Aug 2026 63,379.804−$943.86
long19 Aug 2026 64,725.4012 Sep 2026 77,139.7024$12,414.30
long20 Sep 2026 81,250.0012 Oct 2026 82,046.1022$796.06

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
GRB Long this page—v4 strategy+13.9%3331.1%
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%
Highest High and Lowest Low Channel Strategy by ceyhunhighest lowestv5 strategy−3.7%267.9%
Donchian Channels System [racer8] by racer8highest lowestv4 strategy−3.2%3643.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 8 msYes 1,000 bars in 25 msNot measured
PineTSNo v5 and v6 only—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. 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/// © omkarkondhekar//@version=4strategy("GRBLong", overlay=true)highInput = input(title = "High Days", type = input.integer, defval = 21, minval = 11)lowInput = input(title = "Low Days", type = input.integer, defval = 21, minval = 5)// Configure backtest start date with inputsstartDate = input(title="Start Date", type=input.integer,     defval=1, minval=1, maxval=31)startMonth = input(title="Start Month", type=input.integer,     defval=1, minval=1, maxval=12)startYear = input(title="Start Year", type=input.integer,     defval=2019, minval=1800, maxval=2100)// See if this bar's time happened on/after start dateafterStartDate = (time >= timestamp(syminfo.timezone,     startYear, startMonth, startDate, 0, 0))high21 = highest(high, highInput)low21 = lowest(low, lowInput)diff = high21 - low21longEntrySignal = low > low21 + (diff * 0.382) and close[1] > open[1] strategy.entry("Long", strategy.long, when = longEntrySignal and afterStartDate)strategy.exit("Long Exit", "Long", stop = low21 + (diff * 0.236))plot(low21 + (diff * 0.382), color= color.green)plot(low21 + (diff * 0.236), color = color.red)