Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Grab Trading System

A Pine Script v4 strategy built on Highest (80) and Lowest (80). It has 7 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 4 settings; defaults include Longterm Period 80 and Shortterm Period 21.

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

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • 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 (4)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$124,189$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. Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 16, 17) so the engine trades the way the script says.
Net profit
+21.10%
$21,104.40
Buy and hold
+102.5%
same period
Closed trades
17
11 won · 6 lost
Profitable
64.7%
of closed trades
Profit factor
1.47
gross profit ÷ gross loss
Max drawdown
21.58%
−$30,523.20

One run with the author's default settings, $100,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 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 16, 17. 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, change → ta.change.
  • 2 strategy calls use the when = argument (line 16, 17). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 9: highest → ta.highest
  • Line 10: lowest → ta.lowest
  • Line 11: highest → ta.highest
  • Line 12: lowest → ta.lowest
  • Line 16: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 17: strategy.entry(…, false) → strategy.entry(…, strategy.short)
  • Line 27: change → ta.change
⋯// © LonesomeTheBlue-//@version=4+//@version=5strategy("Grab Trading System", overlay = true)⋯showtrend = input(defval = true, title = "Show Trend")-major_resistance = highest(flb)+major_resistance = ta.highest(flb)-major_support = lowest(flb)+major_support = ta.lowest(flb)-minor_resistance = highest(slb)+minor_resistance = ta.highest(slb)-minor_support = lowest(slb)+minor_support = ta.lowest(slb) ⋯trend := high > major_resistance[1] ? 1 : low < major_support[1] ? -1 : trend-strategy.entry("Buy", true, when = trend == 1 and low[1] == minor_support[1] and low > minor_support)+strategy.entry("Buy", strategy.long, when = trend == 1 and low[1] == minor_support[1] and low > minor_support)-strategy.entry("Sell", false, when = trend == -1 and high[1] == minor_resistance[1] and high < minor_resistance)+strategy.entry("Sell", strategy.short, when = trend == -1 and high[1] == minor_resistance[1] and high < minor_resistance)if strategy.position_size > 0⋯        strategy.close("Sell", comment ="Close Sell")-if strategy.position_size != 0 and change(trend)+if strategy.position_size != 0 and ta.change(trend)    strategy.close_all()⋯

Clean v5

VerifiedDownload the v5 script

Same 17 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.int()
  • Line 7: input() → input.bool()
  • Line 8: input() → input.bool()
  • Line 16: when = trend == 1 and low[1] == minor_support[1] and low > minor_support → if block
  • Line 17: when = trend == -1 and high[1] == minor_resistance[1] and high < minor_resistance → if block
⋯strategy("Grab Trading System", overlay = true)-flb = input(defval = 80, title = "Longterm Period", minval = 1)+flb = input.int(defval = 80, title = "Longterm Period", minval = 1)-slb = input(defval = 21, title = "Shortterm Period", minval = 1)+slb = input.int(defval = 21, title = "Shortterm Period", minval = 1)-showtarget = input(defval = true, title = "Show Target")+showtarget = input.bool(defval = true, title = "Show Target")-showtrend = input(defval = true, title = "Show Trend")+showtrend = input.bool(defval = true, title = "Show Trend")major_resistance = ta.highest(flb)⋯trend := high > major_resistance[1] ? 1 : low < major_support[1] ? -1 : trend-strategy.entry("Buy", strategy.long, when = trend == 1 and low[1] == minor_support[1] and low > minor_support)+if trend == 1 and low[1] == minor_support[1] and low > minor_support+    strategy.entry("Buy", strategy.long)-strategy.entry("Sell", strategy.short, when = trend == -1 and high[1] == minor_resistance[1] and high < minor_resistance)+if trend == -1 and high[1] == minor_resistance[1] and high < minor_resistance+    strategy.entry("Sell", strategy.short)if strategy.position_size > 0⋯

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: 17 before, 28 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.

⋯// © LonesomeTheBlue-//@version=5+//@version=6strategy("Grab Trading System", 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
Longterm Period80int · min 1major_resistance major_support
Shortterm Period21int · min 1minor_resistance minor_support
Show Targettrueboolminr mins plot
Show Trendtrueboolmajr majs plot fill

What it calculates

  • Highest (highest, ta.highest in v5)Longterm Period (80)major_resistance · line 9
  • Lowest (lowest, ta.lowest in v5)Longterm Period (80)major_support · line 10
  • Highest (highest, ta.highest in v5)Shortterm Period (21)minor_resistance · line 11
  • Lowest (lowest, ta.lowest in v5)Shortterm Period (21)minor_support · line 12

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.

flbLongterm Periodsetting · 80slbShortterm Periodsetting · 21lowlowprice datahighhighprice datamajor_resistanceHighest→ major_resistancemajor_supportLowest→ major_supportminor_resistanceHighest→ minor_resistanceminor_supportLowest→ minor_supporttrendtrendvalueentry:BuyOpen Buystrategy.entryentry:SellOpen Sellstrategy.entryexit:Buyexit Buystrategy.exitclose:BuyClose Buystrategy.closeexit:Sellexit Sellstrategy.exitclose:SellClose Sellstrategy.closeclose_all:close_all strategy.close_allplot:30plotplotplot:31plotplotplot:32plotplotplot:33plotplotfill:34Fillfill × 2fill:35Fillfill × 2

Order rules

OrderFires whenBy defaultLine
Open Buy longtrend == 1 and low[1] == minor_support[1] and low > minor_supportOn16
Open Sell shorttrend == -1 and high[1] == minor_resistance[1] and high < minor_resistanceOn17
Exit Buy stopstrategy.position_size > 0On19
Close Buyhigh[1] == minor_resistance[1] and high < minor_resistanceOn21
Exit Sell stopstrategy.position_size < 0On24
Close Selllow[1] == minor_support[1] and low > minor_supportOn26
Close strategy.position_size != 0 and change(trend)On28

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.

5/5trades 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+21.1%+102.5%1765%1.4721.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.7%+5.5%1540%0.944.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.6%+9.8%1050%1.311.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.4%+8.4%1567%2.080.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.1%+16.7%1346%0.580.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%1464%0.890.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%1765%1.010.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%1464%2.910.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 market667%$9,186.27
Sideways market771%$23,200.60
Falling market450%−$11,282.60

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

How bad could the drawdown be?

24.2%

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

0%28%
All 17 trades
SideEntryExitBarsP&L
short19 Jul 2024 63,987.907 Aug 2024 56,022.0019$7,965.92
short25 Aug 2024 64,157.006 Sep 2024 56,180.0012$7,977.02
short22 Sep 2024 63,349.0012 Oct 2024 62,540.0020$808.98
short18 Oct 2024 67,421.8019 Oct 2024 68,428.001−$1,006.21
long1 Jan 2025 93,576.0019 Jan 2025 104,556.0018$10,980.20
long5 Feb 2025 97,763.1025 Feb 2025 89,256.7020−$8,506.45
short25 Apr 2025 93,980.508 May 2025 99,475.0013−$5,494.53
long7 Jun 2025 104,288.005 Jul 2025 107,984.0028$3,695.82
long5 Aug 2025 115,055.0013 Aug 2025 120,134.008$5,079.06
long24 Aug 2025 115,438.0020 Sep 2025 115,632.0027$194.33
long28 Sep 2025 109,636.005 Oct 2025 122,391.007$12,755.10
short11 Dec 2025 92,015.4023 Jan 2026 89,559.7043$2,455.70
short6 Mar 2026 70,891.0029 Mar 2026 66,377.0023$4,513.98
short13 Apr 2026 70,741.6022 Apr 2026 79,424.009−$8,682.44
long25 May 2026 77,065.003 Jun 2026 65,000.009−$12,065.00
short17 Jul 2026 63,830.2021 Aug 2026 73,400.0035−$9,569.80
long17 Sep 2026 76,206.0023 Sep 2026 86,208.606$10,002.60

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
Grab Trading System this page—v4 strategy+21.1%1721.6%
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 16 msWith a workaround 1,000 bars in 38 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 16, 17) so the engine trades the way the script says.

“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/// © LonesomeTheBlue//@version=4strategy("Grab Trading System", overlay = true)flb = input(defval = 80, title = "Longterm Period", minval = 1)slb = input(defval = 21, title = "Shortterm Period", minval = 1)showtarget = input(defval = true, title = "Show Target")showtrend = input(defval = true, title = "Show Trend")major_resistance = highest(flb)major_support = lowest(flb)minor_resistance = highest(slb)minor_support = lowest(slb) var int trend = 0trend := high > major_resistance[1] ? 1 : low < major_support[1] ? -1 : trendstrategy.entry("Buy", true, when = trend == 1 and low[1] == minor_support[1] and low > minor_support)strategy.entry("Sell", false, when = trend == -1 and high[1] == minor_resistance[1] and high < minor_resistance)if strategy.position_size > 0    strategy.exit("Buy", stop = major_support, comment = "Stop Buy")    if high[1] == minor_resistance[1] and high < minor_resistance        strategy.close("Buy", comment ="Close Buy")    if strategy.position_size < 0    strategy.exit("Sell", stop = major_resistance, comment = "Stop Sell")    if low[1] == minor_support[1] and low > minor_support        strategy.close("Sell", comment ="Close Sell")if strategy.position_size != 0 and change(trend)    strategy.close_all()    majr = plot(major_resistance, color = showtrend and trend == -1 and trend[1] == -1 ? color.red : na)majs = plot(major_support, color = showtrend and trend == 1 and trend[1] == 1 ? color.lime : na)minr = plot(minor_resistance, color = showtarget and trend == 1 and strategy.position_size > 0 ? color.yellow : na, style = plot.style_circles)mins = plot(minor_support, color = showtarget and trend == -1 and strategy.position_size < 0 ? color.yellow : na, style = plot.style_circles)fill(majs, mins, color = showtrend and trend == 1 and trend[1] == 1 ? color.new(color.lime, 85) : na)fill(majr, minr, color = showtrend and trend == -1 and trend[1] == -1 ? color.new(color.red, 85) : na)